예제 #1
0
        public static IEnumerable <Role> GetRoles(IEnumerable <RoleMedia> roleMediaDetails)
        {
            var roles = new List <Role>();

            foreach (var role in roleMediaDetails.Select(item => RolesMapper.GetByID(item.RoleID)).Where(role => roles.Where(i => i.ID == role.ID).Count() == 0))
            {
                roles.Add(role);
            }

            return(roles);
        }
예제 #2
0
        public static bool HasPermission(PermissionsEnum permissionsEnum, User user)
        {
            var permission = PermissionsMapper.GetPermissionsFromEnum(permissionsEnum);

            if (permission == null)
            {
                return(false);
            }

            var roles = RolesMapper.FilterWithPermission(user.Roles, permission);

            return(roles.Any());
        }
예제 #3
0
 public bool IsInRole(string role)
 {
     return(IsInRole(RolesMapper.GetEnumByName(role)));
 }
예제 #4
0
 public bool IsInRole(RoleEnum roleEnum)
 {
     return(IsInRole(RolesMapper.GetByEnum(roleEnum)));
 }
예제 #5
0
 public static IEnumerable <User> GetAllByRoleEnum(RoleEnum roleEnum)
 {
     return(GetAllByRole(RolesMapper.GetByEnum(roleEnum)));
 }