public async Task <IPagedList <RoleListOutput> > GetRolesAsync(RequestRoleListCommand command) { var a = command.FilteringOptions?.Count > 0; var query = _roleManager.Roles.Where( predicate => predicate.Name.Contains(command.FilteringOptions[0].Value as string)) .OrderBy(string.IsNullOrEmpty(command.SortingOptions?.First().Field) ? "Name" : command.SortingOptions?.First().Field); var rolesCount = await query.CountAsync().ConfigureAwait(false); IEnumerable <RoleListOutput> roleListOutput = _mapper.Map <List <RoleListOutput> >(await query.ToArrayAsync().ConfigureAwait(false)); var pageCount = rolesCount / command.PageSize; return(new PagedList <RoleListOutput>(command.PageIndex, command.PageSize, rolesCount, pageCount, roleListOutput)); }
public async Task <ActionResult <IPagedList <RoleListOutput> > > GetRoles([FromQuery] RequestRoleListCommand command) { return(Ok(await _mediator.Send(command))); }