public ViewResult Index(int? page, string sort, string sortdir)
{
ViewBag.RowsPerPage = BgResources.Pager_CategoriesPerPage;
ViewBag.TotalCategories = CategoryServices.TotalNumberOfEntity();
var pageIndex = page ?? 0;
bool dir;
if (sortdir == null)
{
dir = false;
}
else
{
dir = sortdir.Equals("ASC", StringComparison.CurrentCultureIgnoreCase) ? true : false;
}
if (sort == null)
{
return View(CategoryServices.RetrievePaged(pageIndex, Int32.Parse(BgResources.Pager_CategoriesPerPage), c => c.DateCreated, false));
}
else
{
switch (sort.ToLower())
{
case "name":
return View(CategoryServices.RetrievePaged(pageIndex, Int32.Parse(BgResources.Pager_CategoriesPerPage), c => c.Name, dir));
case "datecreated":
return View(CategoryServices.RetrievePaged(pageIndex, Int32.Parse(BgResources.Pager_CategoriesPerPage), c => c.DateCreated, dir));
default:
return View(CategoryServices.RetrievePaged(pageIndex, Int32.Parse(BgResources.Pager_CategoriesPerPage), c => c.DateCreated, false));
}
}
}