public bool IsInRole(ROLES role) { var roles = Roles.GetRolesForUser(UserName); foreach (var r in roles) { if (r.Equals(role.ToString())) return true; } return false; }
public static string RoleDescription(ROLES role) { switch (role) { case ROLES.Administrator: return(Resources.AppResources.EventMembershipDescriptionAdministrator); case ROLES.Moderator: return(Resources.AppResources.EventMembershipDescriptionModerator); case ROLES.Contributor: return(Resources.AppResources.EventMembershipDescriptionContributor); case ROLES.Viewer: return(Resources.AppResources.EventMembershipDescriptionContributor); default: throw new ArgumentException($"Role {role.ToString()} not known"); } }
public UserEntity(User User, params object[] args) : base(User) { ROLES Roles = ROLES.USER; if (User.Admin != null) { Roles = Roles | ROLES.ADMIN; } if (User.Student != null) { Roles |= ROLES.STUDENT; } if (User.Lecturer != null) { Roles |= ROLES.LECTURER; } this.Roles = Roles.ToString().Replace(" ", "").Split(",").ToList(); foreach (var arg in args) { if (arg is Student) { this.Student = new StudentEntity((Student)arg); } if (arg is Admin) { this.Admin = new AdminEntity((Admin)arg); } if (arg is Lecturer) { this.Lecturer = new LecturerEntity((Lecturer)arg); } } }