// GET: Admin/ListCategory public ActionResult Index(string SortOrder, string SortBy, string Page) { ViewBag.SortOrder = SortOrder; ViewBag.SortBy = SortBy; var categories = objBs.GetAll(); switch (SortBy) { case "CategoryName": switch (SortOrder) { case "Asc": categories = categories.OrderBy(x => x.CategoryName).ToList(); break; case "Desc": categories = categories.OrderByDescending(x => x.CategoryName).ToList(); break; default: break; } break; case "CategoryDesc": switch (SortOrder) { case "Asc": categories = categories.OrderBy(x => x.CategoryDesc).ToList(); break; case "Desc": categories = categories.OrderByDescending(x => x.CategoryDesc).ToList(); break; default: break; } break; default: categories = categories.OrderBy(x => x.CategoryName).ToList(); break; } ViewBag.TotalPages = Math.Ceiling(objBs.GetAll().Count() / 10.0); int page = int.Parse(Page == null ? "1" : Page); ViewBag.Page = page; categories = categories.Skip((page - 1) * 10).Take(10); return(View(categories)); }
// GET: User/URL public ActionResult Index() { ViewBag.CategoryId = new SelectList(objCatBs.GetAll().ToList(), "CategoryId", "CategoryName"); ViewBag.UserId = new SelectList(objUserBs.GetAll().ToList(), "UserId", "UserEmail"); //LinkHubDbEntities db = new LinkHubDbEntities(); //ViewBag.CategoryId = new SelectList(db.tbl_Category, "CategoryId", "CategoryName"); return(View()); }