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);
        }
        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());
        }
Exemple #3
0
 public bool IsInRole(string role)
 {
     return(IsInRole(RolesMapper.GetEnumByName(role)));
 }
Exemple #4
0
 public bool IsInRole(RoleEnum roleEnum)
 {
     return(IsInRole(RolesMapper.GetByEnum(roleEnum)));
 }
 public static IEnumerable <User> GetAllByRoleEnum(RoleEnum roleEnum)
 {
     return(GetAllByRole(RolesMapper.GetByEnum(roleEnum)));
 }