// GET: Kategoria public ActionResult IndexCV(int?page, string sortOrder) { int currentPage = page ?? 1; int naStronie = 10; ViewBag.CurrentSort = sortOrder; ViewBag.NazwaSort = sortOrder == "NazwaAsc" ? "Nazwa" : "NazwaAsc"; ViewBag.OpisSort = sortOrder == "OpisAsc" ? "Opis" : "OpisAsc"; ViewBag.IloscOfertSort = sortOrder == "IloscOfertAsc" ? "IloscOfert" : "IloscOfertAsc"; var kategorie = _repo.PobierzKategorieCV(); switch (sortOrder) { case "Nazwa": kategorie = kategorie.OrderByDescending(s => s.Nazwa); break; case "NazwaAsc": kategorie = kategorie.OrderBy(s => s.Nazwa); break; case "Opis": kategorie = kategorie.OrderByDescending(s => s.Nazwa); break; case "OpisAsc": kategorie = kategorie.OrderBy(s => s.Opis); break; case "IloscOfert": kategorie = kategorie.OrderByDescending(s => s.LiczbaOfert); break; case "IloscOfertAsc": kategorie = kategorie.OrderBy(s => s.LiczbaOfert); break; } return(View(kategorie.ToPagedList <KategoriaCVViewModel>(currentPage, naStronie))); }