/// <summary> /// Page Index /// </summary> /// <param name="sort"> "ID", "Name"</param> /// <param name="type"> "asc", "desc"</param> /// <param name="curPage"></param> /// <param name="pageSize"></param> /// <param name="option"> "Managing", "Deleted'</param> /// <returns></returns> public ActionResult Index(string sort = "ID", string type = "asc", int curPage = 1, int pageSize = 5, string option = "Managing") { int total; // count all the results base on option (Managing or Deleted) // ViewBag.IDSortType = shopService.ChangeSortType(type, sort == "ID"); ViewBag.NameSortType = shopService.ChangeSortType(type, sort == "Name"); ViewBag.AddressSortType = shopService.ChangeSortType(type, sort == "Address"); ViewBag.DescriptionSortType = shopService.ChangeSortType(type, sort == "Description"); ViewBag.Sort = sort; ViewBag.MyStyle = type; ViewBag.Option = option; List <Shop> lstShop; if (option == "Managing") { lstShop = shopService.GetAllNonDeleteWithPaginationAndSort(sort, type, curPage, pageSize).ToList(); total = shopService.GetAllNonDelete().Count(); } else // Deleted { lstShop = shopService.GetAllDeletedWithPaginationAndSort(sort, type, curPage, pageSize).ToList(); total = shopService.GetAllDeleted().Count(); } int nPages = total / pageSize; if (total % pageSize > 0) { nPages++; } ViewBag.Pages = nPages; ViewBag.curPage = curPage; ViewBag.NextPage = curPage + 1; ViewBag.PrevPage = curPage - 1; return(View(lstShop.ToList())); }