예제 #1
0
        //[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
                   ));
        }