public ActionResult List( int pageIndex = 1, int pageSize = 24, string pageOrder = "OrderID") { if (pageIndex > 0) { pageIndex = pageIndex - 1; } else { pageIndex = 0; } int count; var packageList = Packages.GetList(pageIndex, pageSize, pageOrder); count = Packages.CountList(); var totalPages = (int)Math.Ceiling((decimal)count / pageSize); var paging = Utilities.MakePaging(totalPages, pageIndex + 1); if (totalPages > 1) { ViewBag.HasPaging = true; if (pageIndex == 0) { ViewBag.PrevPage = (int?)null; } else { ViewBag.PrevPage = (pageIndex); } if (pageIndex == totalPages - 1) { ViewBag.NextPage = (int?)null; } else { ViewBag.NextPage = (pageIndex + 2); } } var model = new PackageListSettings { Packages = packageList, Paging = paging, TotalPages = totalPages, CurrentPageIndex = pageIndex }; return(View(model)); }
public JsonResult AjaxList( int pageIndex, int pageSize, string pageOrder = "OrderID") { if (pageIndex > 0) { pageIndex = pageIndex - 1; } else { pageIndex = 0; } var jsonSuccessResult = new JsonSuccessResult(); try { var packageList = Packages.GetList(pageIndex, pageSize, pageOrder); int count = Packages.CountList(); var totalPages = (int)Math.Ceiling((decimal)count / pageSize); var paging = Utilities.MakePaging(totalPages, pageIndex + 1); ViewBag.Title = "بسته های محصولات - صفحه " + (pageIndex + 1); var model = new PackageListSettings { Packages = packageList, Paging = paging, TotalPages = totalPages, CurrentPageIndex = pageIndex, PageTitle = ViewBag.Title }; jsonSuccessResult.Data = model; jsonSuccessResult.Success = true; } catch (Exception ex) { jsonSuccessResult.Errors = new string[] { ex.Message }; jsonSuccessResult.Success = false; } return(new JsonResult() { Data = jsonSuccessResult }); }