public async Task <List <UserRoleForListDto> > GetUserRoles(User user) { var spec = new UserWithRoleSpecification(user); var userRoles = await roleDal.ListEntityWithSpecAsync(spec); if (userRoles == null) { throw new RestException(HttpStatusCode.BadRequest, new { UserNotFound = Messages.UserClaimsNotFound }); } var userRolesForReturn = mapper.Map <List <Role>, List <UserRoleForListDto> >(userRoles); return(userRolesForReturn); }
//[SecuredOperation("Sudo,Roles.List,Roles.All", Priority = 1)] public async Task <Pagination <RoleForListDto> > GetRolesAsync(RoleQueryParams queryParams) { var spec = new RolesWithRoleCategorySpecification(queryParams); var roles = await roleDal.ListEntityWithSpecAsync(spec); var countSpec = new RolesWithFilterForCountSpecificatipon(queryParams); var totalItems = await roleDal.CountAsync(countSpec); if (roles == null) { throw new RestException(HttpStatusCode.BadRequest, new { RolesListNotFound = Messages.RoleListNotFound }); } ; var data = mapper.Map <List <Role>, List <RoleForListDto> >(roles); return(new Pagination <RoleForListDto> ( queryParams.PageIndex, queryParams.PageSize, totalItems, data )); }