public ActionResult Index(int?page, string sortOrder, string search, bool descending = true, bool reversable = false) { ManageSearchingTermStatus(ref search); IEnumerable <Order> model = GetSearchingResult(search); if (model.Count() == 0) { model = _orderRepository.GetAll(); } if (reversable) { ReverseSorting(ref descending, sortOrder); } IEnumerable <OrderAdminViewModel> mappedModel = Mapper.Map <IEnumerable <OrderAdminViewModel> >(model); IEnumerable <OrderAdminViewModel> sortedModel = PagedListHelper.SortBy(mappedModel, x => x.Created, sortOrder, descending); int pageNumber = page ?? 1; IPagedList <OrderAdminViewModel> viewModel = sortedModel.ToPagedList(pageNumber, 25); SaveSortingState(sortOrder, descending, search); return(View(viewModel)); }
public ActionResult Index(int?page, string sortOrder, bool descending = true, bool reversable = false) { AppUser user = GetCurrentUser(); if (reversable) { ReverseSorting(ref descending, sortOrder); } IEnumerable <Order> model = user.Orders; IEnumerable <OrderViewModel> mappedModel = Mapper.Map <IEnumerable <OrderViewModel> >(model); IEnumerable <OrderViewModel> sortedModel = PagedListHelper.SortBy(mappedModel, x => x.Created, sortOrder, descending); int pageNumber = page ?? 1; IPagedList <OrderViewModel> viewModel = sortedModel.ToPagedList(pageNumber, 5); viewModel = viewModel.Select(x => { x.Created = x.Created.ToLocalTime(); return(x); }); SaveSortingState(sortOrder, descending); if (Request.IsAjaxRequest()) { return(PartialView(viewModel)); } return(View(viewModel)); }
public PartialViewResult GetSpecialOffersInDeck(int?page, string sortOrder, bool descending = true) { IQueryable <Product> model = _productRepository.GetAllShowingInDeck(); IEnumerable <ProductViewModel> mappedModel = Mapper.Map <IEnumerable <ProductViewModel> >(model); IEnumerable <ProductViewModel> sortedModel = PagedListHelper.SortBy(mappedModel, x => x.Name, sortOrder, descending); int pageNumber = page ?? 1; IPagedList <ProductViewModel> viewModel = sortedModel.ToPagedList(pageNumber, 9); SaveSortingState(sortOrder, descending); return(PartialView("_ProductsDeck", viewModel)); }
public PartialViewResult ProductsToPagedList(IEnumerable <ProductViewModel> model, int?page) { string sortOrder = null; bool descending = false; if (SortingManager.SortOrder != null) { sortOrder = SortingManager.SortOrder; descending = SortingManager.IsSortDescending; SortingManager.SetSorting(sortOrder, descending); } IEnumerable <ProductViewModel> sortedModel = PagedListHelper.SortBy(model, x => x.Name, sortOrder, descending); int pageNumber = page ?? 1; IPagedList <ProductViewModel> viewModel = new PagedList <ProductViewModel>(sortedModel, pageNumber, 9); return(PartialView("_ProductsDeck", viewModel)); }
public ActionResult Search(int?page, string sortOrder, string search, bool descending = true) { ManageSearchingTermStatus(ref search); IEnumerable <Product> model = GetSearchingResult(search); if (model.Count() == 0) { model = _productRepository.GetAll(); } IEnumerable <ProductViewModel> mappedModel = Mapper.Map <IEnumerable <ProductViewModel> >(model); IEnumerable <ProductViewModel> sortedModel = PagedListHelper.SortBy(mappedModel, x => x.Name, sortOrder, descending); int pageNumber = page ?? 1; IPagedList <ProductViewModel> viewModel = sortedModel.ToPagedList(pageNumber, 9); SaveSortingState(sortOrder, descending, search); return(View("_ProductsDeck", viewModel)); }