BgEngine.Infraestructure.Security.CodeFirstRoleProvider.RoleExists C# (CSharp) Метод

RoleExists() публичный Метод

public RoleExists ( string roleName ) : bool
roleName string
Результат bool
        public override bool RoleExists(string roleName)
        {
            if (string.IsNullOrEmpty(roleName))
                    {
                        throw CreateArgumentNullOrEmptyException("roleName");
                    }
                    using (BlogUnitOfWork context = new BlogUnitOfWork(new ModelContextInit()))
                    {
                        dynamic result = context.Roles.FirstOrDefault(Rl => Rl.RoleName == roleName);
                        if (result != null)
                        {
                            return true;
                        }
                        else
                        {
                            return false;
                        }
                    }
        }

Usage Example

Пример #1
0
 public static bool RoleExist(string role)
 {
     CodeFirstRoleProvider rp = new CodeFirstRoleProvider();
     return rp.RoleExists(role);
 }