// GET: People public ActionResult Index(string sortParam, string sortOrder, string proffesion, int?pageSize, int?page) { IEnumerable <People> peoples = db.Peoples.Include(p => p.Proffesion).Include(p => p.UserRates).ToList(); ViewBag.SortParam = new SelectList(new[] { "Nazwisko", "Imię", "Data urodzenia", "Oceny" }, sortParam); ViewBag.SortOrder = new SelectList(SortOrder(), sortOrder); ViewBag.Proffesion = new SelectList(Proffesion.GetProffesions(), proffesion); ViewBag.PageSize = new SelectList(PageSizes(), pageSize); ViewBag.NoContent = "Brak postaci kina spełniających warunek :("; int pagesize = (pageSize ?? DefPageSize); int pageNumber = (page ?? DefPageNo); peoples = SwitchProffesion(peoples, proffesion); peoples = SortPeoples(peoples, sortParam, sortOrder); if (Request.IsAjaxRequest()) { return(PartialView("_TileList", peoples.ToPagedList(pageNumber, pagesize))); } return(View(peoples.ToPagedList(pageNumber, pagesize))); }
/* TODO */ public ActionResult Index(string id, string rate, string genre, string proffesion, int?pageSize, int?page) { CheckID(id); var UserID = User.Identity.GetUserId(); ViewBag.ID = id; ViewBag.UserID = UserID; ViewBag.PageSize = new SelectList(PageSizes(), pageSize); ViewBag.Genre = new SelectList(MovieGenre.GetTypes(), genre); ViewBag.Proffesion = new SelectList(Proffesion.GetProffesions(), proffesion); ViewBag.Rate = new SelectList(UserRate.GetRateRange(), rate); ViewBag.ProfileInfoes = true; ViewBag.RatesCount = new int[UserRate.GetRateRange().Count()]; int pagesize = (pageSize ?? DefPageSize); int pageNumber = (page ?? DefPageNo); if (id == "Movies") { ViewBag.NoContent = "Brak filmów spełniających warunek :("; ViewBag.Controller = "Movies"; IEnumerable <Movie> movies = db.Movies.Include(m => m.Genre).Include(m => m.UserRates).Where(m => m.UserRates.Any(ur => ur.UserID == UserID)).ToList(); ViewBag.Count = movies.Count(); for (int i = 0; i < UserRate.GetRateRange().Count(); i++) { ViewBag.RatesCount[i] = movies.Where(t => t.UserRates.Any(ur => ur.Rate == i + 1 && ur.UserID == ViewBag.UserID)).Count(); } movies = SwitchGenre(movies, genre); movies = FilterRate(movies, rate, UserID); if (Request.IsAjaxRequest()) { return(PartialView("_TileList", movies.ToPagedList(pageNumber, pagesize))); } return(View(movies.ToPagedList(pageNumber, pagesize))); } else if (id == "People") { ViewBag.NoContent = "Brak postaci kina spełniających warunek :("; ViewBag.Controller = "People"; IEnumerable <People> peoples = db.Peoples.Include(p => p.Proffesion).Include(p => p.UserRates).Where(p => p.UserRates.Any(ur => ur.UserID == UserID)).ToList(); ViewBag.Count = peoples.Count(); for (int i = 0; i < UserRate.GetRateRange().Count(); i++) { ViewBag.RatesCount[i] = peoples.Where(t => t.UserRates.Any(ur => ur.Rate == i + 1 && ur.UserID == ViewBag.UserID)).Count(); } peoples = SwitchProffesion(peoples, proffesion); peoples = FilterRate(peoples, rate, UserID); if (Request.IsAjaxRequest()) { return(PartialView("_TileList", peoples.ToPagedList(pageNumber, pagesize))); } return(View(peoples.ToPagedList(pageNumber, pagesize))); } else { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } }