public ActionResult GenresTable(int page = 1) { ModelState.AddModelError("messages", messagesGenreTable); messagesGenreTable = null; List <Genre> filterGenres = TempData["GenreList"] as List <Genre>; List <Genre> genres = filterGenres ?? genresDb.GetAllGenres(); List <Play> plays = playsDb.GetAllPlays(); Hashtable idAndCountInPlays = new Hashtable(); genres.ForEach(genre => idAndCountInPlays.Add(genre.Id, plays.Where(play => play.GenreId == genre.Id).Count())); ViewBag.idAndCountInPlay = idAndCountInPlays; int sizeForPage = pageSize; pageSize = normalyPageSize; page = truePage(page, (int)Math.Ceiling((double)genres.Count / pageSize)); return(View(genres.ToPagedList(page, pageSize))); }
// GET: Home public ActionResult Index(int page = 1) { ViewBag.Authors = authorsDb.GetAllAuthors(); ViewBag.Genres = genresDb.GetAllGenres(); List <DatePlay> sortedDates = datesDb.GetAllDates().OrderBy(x => x.Date).ToList(); ViewBag.Dates = sortedDates; var sortedPlays = playsDb.GetAllPlays().OrderBy(a => a.Name).ToList() .Where(play => sortedDates.Where(date => date.PlayId == play.Id).Count() > 0); page = truePage(page, (int)Math.Ceiling((double)sortedPlays.Count() / pageSize)); return(View(sortedPlays.ToPagedList(page, pageSize))); }
// GET: Home public ActionResult Index() { IPlayDao playsDb = PlaysTableConnection.Instance; ViewBag.Plays = playsDb.GetAllPlays(); IAuthorDao authorsDb = AuthorsTableConnection.Instance; ViewBag.Authors = authorsDb.GetAllAuthors(); IGenreDao genresDb = GenresTableConnection.Instance; ViewBag.Genres = genresDb.GetAllGenres(); IDateDao datesDb = DatesTableConnection.Instance; ViewBag.Dates = datesDb.GetAllDates().OrderBy(x => x.Date).ToList(); return(View()); }