public Task <FilterResultModel <UserViewModel> > Handle(GetUsersListViewQuery request, CancellationToken cancellationToken) { var sortBy = request.SortBy.Trim() != "" ? request.SortBy : "UserName"; var sortDirection = (request.SortDirection.ToUpper() == "DESCENDING") ? true : false; FilterResultModel <UserViewModel> result = new FilterResultModel <UserViewModel> (); var vehicle = _userManager.Users .Select(UserViewModel.Projection) .Select(DynamicQueryHelper.GenerateSelectedColumns <UserViewModel> (request.SelectedColumns)) .AsQueryable(); if (request.Filter.Count() > 0) { vehicle = vehicle .Where(DynamicQueryHelper .BuildWhere <UserViewModel> (request.Filter)).AsQueryable(); } result.Count = vehicle.Count(); var PageSize = (request.PageSize == 0) ? result.Count : request.PageSize; var PageNumber = (request.PageSize == 0) ? 1 : request.PageNumber; result.Items = vehicle.OrderBy(sortBy, sortDirection) .Skip(PageNumber - 1) .Take(PageSize) .ToList(); return(Task.FromResult <FilterResultModel <UserViewModel> > (result)); }
public async Task <ActionResult <IEnumerable <UserViewModel> > > GetAllUsers([FromQuery] GetUsersListViewQuery query) { var user = await _Mediator.Send(query); return(StatusCode(200, user)); }
public async Task <IEnumerable <UserViewModel> > Handle(GetUsersListViewQuery request, CancellationToken cancellationToken) { return(await _userManger.Users .Select(UserViewModel.Projection) .ToListAsync()); }