public ViewResult Index(int?page, Sorting.SortValue?sortedBy, bool?asc) { var operations = operationsManager.getOperations(); var operationsModel = operations .Select(Mapper.Map <OperationViewModel>); OperationsListViewModel model = new OperationsListViewModel(); SortOperations(model, sortedBy, asc); PaginateOperations(model, page); return(View(model)); }
private void PaginateOperations(OperationsListViewModel model, int?page) { model.Paging.Page = page ?? 1; model.Operations = model.Operations.ToList().ToPagedList(model.Paging.Page, SharedConstants.PAGE_SIZE); }
private void SortOperations(OperationsListViewModel model, Sorting.SortValue?sortedBy, bool?asc) { model.Sorting.SortedBy = sortedBy ?? Sorting.SortValue.Date; model.Sorting.Asc = asc ?? true; model.Operations = operationsManager.getSortedOperations(model.Sorting.SortedBy, model.Sorting.Asc).ToList(); }