public IActionResult Index(string sortOrder, string searchString, string currentFilter, int?page) { ViewBag.lisEmail = _userProfileDatabase.Find(s => s.IsDeleted == false).ToList(); ViewData["NameSortParm"] = string.IsNullOrEmpty(sortOrder) ? "name_desc" : ""; if (searchString != null) { page = 1; } else { searchString = currentFilter; } ViewData["CurrentFilter"] = searchString; BillListViewModel model = new BillListViewModel() { ListBill = _billDatabase.GetAll().ToList() }; if (!string.IsNullOrEmpty(searchString)) { model.ListBill = model.ListBill.Where(s => s.CreatedDate.ToShortDateString().ToLower().Contains(searchString.ToLower())).ToList(); } switch (sortOrder) { case "name_desc": model.ListBill = model.ListBill.OrderByDescending(s => s.CreatedDate).ToList(); break; } int pageSize = 10; return(View(PaginatedProductList <Bill> .Create(model.ListBill.AsQueryable(), page ?? 1, pageSize))); }
public ActionResult Index() { var model = new BillListViewModel(); model.Bills = _billService.GetList(); return(View(model)); }
public static BillListViewModel GetBills(int page, int pageSize) { int totalBills = 0; var model = new BillListViewModel(); page = page - 1; if (page <= 0) { page = 0; } model.Bills = EconomyDataService.GetBills(page, pageSize, out totalBills); model.Paging = new Paging(totalBills, page + 1, pageSize); return(model); }
public IActionResult Index(int?id) { var vm = new BillListViewModel(); vm.Bills = _context.GetBills(CustomerId); if (vm.Bills.Count == 0) { return(View(vm)); } var paginated = new Paginator <BillPay>(vm.Bills, id ?? 1); //go to first page if there was an error if (paginated.partialList == null) { return(RedirectToAction(nameof(Index), new { id = 1 })); } vm.Bills = paginated.partialList; vm.currentPage = paginated.currentPage; vm.nextPage = paginated.nextPage; vm.prevPage = paginated.prevPage; return(View(vm)); }