Exemplo n.º 1
0
        public async Task <bool> RevokeRole(User user, RoleType roleType)
        {
            if (user == null)
            {
                throw new EntityNotFoundException("User not found");
            }

            var query = RoleTypeSmartEnum.FromValue((int)roleType).Revoke(user.Id);

            return(await database.Execute(query));
        }
Exemplo n.º 2
0
        public static SqlQuery BuildIsPermittedQuery(int userId, params RoleType[] roleTypes)
        {
            string rolesConditions = string.Empty;

            roleTypes.ToList()
            .ForEach(r => rolesConditions += RoleTypeSmartEnum.FromValue((int)r).IsPermitted().Query);

            return(new SqlBuilder()
                   .Exists(new SqlBuilder()
                           .Select()
                           .From(RepositoryDictionary.FindTable(typeof(IUserRepository)))
                           .Where("id")
                           .Equals
                           .Append(userId)
                           .And
                           .Open
                           .Append(rolesConditions)
                           .Build())
                   .Close
                   .As("IsPermitted")
                   .Build());
        }
Exemplo n.º 3
0
        public async Task <bool> RevokeRole(int userId, RoleType roleType)
        {
            var query = RoleTypeSmartEnum.FromValue((int)roleType).Revoke(userId);

            return(await database.Execute(query));
        }