本文整理汇总了C#中User.IsInRole方法的典型用法代码示例。如果您正苦于以下问题:C# User.IsInRole方法的具体用法?C# User.IsInRole怎么用?C# User.IsInRole使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类User
的用法示例。
在下文中一共展示了User.IsInRole方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FillField
public override string FillField(BaseDataMap map, object importRow,
ref User user,
string importValue,
out bool updatedField)
{
updatedField = false;
var errorMessage = String.Empty;
var shouldBeMemberOfRole = !String.IsNullOrEmpty(importValue) &&
importValue.Trim() == TrueValue;
var role = InitializeRoleFromString(RoleName, ref errorMessage);
if (role != null)
{
if (!user.IsInRole(role) && shouldBeMemberOfRole)
{
user.Roles.Add(role);
updatedField = true;
}
else if (user.IsInRole(role) && !shouldBeMemberOfRole)
{
user.Roles.Remove(role);
updatedField = true;
}
}
return errorMessage;
}
示例2: CreateIndexViewModel
private DashboardViewModel CreateIndexViewModel(User user, Team team, IRepository repository)
{
var model = new DashboardViewModel();
model.UserIsAdmin = user.IsInRole(Roles.Administrators);
model.UserFullName = user.FullName;
model.SkillLevelCalculation = new SkillLevelCalculationViewModel(user, repository);
if (null != team) {
model.CurrentSeasonStats = GetCurrentSeasonStatsViewModel(user, team);
model.HasCurrentSeasonStats = model.CurrentSeasonStats != null;
model.LastMeetStats = GetLastMeetStats(user, team);
model.HasLastMeetStats = model.LastMeetStats != null;
model.SeasonResults = GetSeasonResults(user, team);
model.HasSeasonResults = model.SeasonResults != null;
}
return model;
}
示例3: IsInRole_is_always_false
public void IsInRole_is_always_false()
{
user = new Guest();
user.IsInRole("anything").Should().BeFalse();
}
示例4: AddUserToStandardRoles
protected virtual void AddUserToStandardRoles(User user, object importRow)
{
// Add standardroles
foreach (var role in AddUserToWhatStandardRoles)
{
if (!user.IsInRole(role))
{
user.Roles.Add(role);
}
}
}
示例5: UpdateRolesOnUser
protected virtual bool UpdateRolesOnUser(User user, object importRow)
{
bool updatedRoles = false;
// Change roles membership
foreach (var role in OnPresentInImportAddToRoles)
{
if (!user.IsInRole(role))
{
user.Roles.Add(role);
updatedRoles = true;
}
}
foreach (var role in OnPresentInImportRemoveFromRoles)
{
if (user.IsInRole(role))
{
user.Roles.Remove(role);
updatedRoles = true;
}
}
return updatedRoles;
}
示例6: ProcessUserNotPresentInImport
protected virtual void ProcessUserNotPresentInImport(User user, ref string errorMessage)
{
if (user != null)
{
foreach (var role in OnNotPresentInImportAddToRoles)
{
if (!user.IsInRole(role))
{
user.Roles.Add(role);
}
}
foreach (var role in OnNotPresentInImportRemoveFromRoles)
{
if (user.IsInRole(role))
{
user.Roles.Remove(role);
}
}
if (IsDeleteUsersWithMembershipInStandardRolesOnly)
{
DeleteUsersWithMembershipInStandardRolesOnly(user, ref errorMessage);
}
}
else
{
errorMessage +=
String.Format(
"The user was null. Therefore the ProcessUserNotPresentInImport method could not be completed.");
}
}
示例7: IsInRole_returns_true
public void IsInRole_returns_true()
{
user = new User();
user.IsInRole("anything").Should().BeTrue();
}
示例8: UserCanEnterMatchResults
public virtual bool UserCanEnterMatchResults(User user)
{
if (null == user) {
return false;
}
// first check to see if this user is a member of the teams in the meet
if (Teams.Where(t => t.Players.Contains(user)).Any()) {
return true;
}
// next, check for role access
if (user.IsInRole(Roles.Administrators) ||
user.IsInRole(Roles.Officers)) {
return true;
}
// if we haven't met any of these criteria, return false
return false;
}