public ViewResult List(string status, string sort = "ClientId", int page = 1, int pageSize = 10) { ClientsListViewModel model = new ClientsListViewModel(); model.PagingInfo = new PagingInfo { CurrentPage = page, ItemsPerPage = pageSize, }; var _clients = status == null ? repository.Clients : repository.Clients.Where(e => e.Status.ToString() == status); model.CurrentStatus = status; model.CurrentSort = sort; model.CurrentPageSaze = pageSize; model.PagingInfo.TotalItems = _clients.Count(); model.Clients = repository.Clients .Where(c => ((status == null) || (c.Status.ToString() == status))) .OrderBy(sort) .Skip((page - 1)*pageSize) .Take(pageSize); return View(model); }
public ViewResult List(string address, int page = 1) { ClientsListViewModel model = new ClientsListViewModel { Clients = repository.Clients .Where(c => address == null || c.Address == address) .OrderBy(c => c.ClientId) .Skip((page - 1)*PageSize) .Take(PageSize), PagingInfo = new PagingInfo { CurrentPage = page, ItemsPerPage = PageSize, TotalItems = address == null ? repository.Clients.Count() : repository.Clients.Where(e => e.Address == address).Count() }, CurrentAddress = address }; return View(model); }