public ActionResult Index() { @ViewBag.Category = MainCategory.Home; List<HomepageAlbumModel> models = new List<HomepageAlbumModel>(); AlbumRepository repo = new AlbumRepository(); models.Add(new HomepageAlbumModel() { Name = "Popular", Albums = Helpers.Convert(repo.GetMostPopular(ALBUMS_IN_CATEGORY)) }); models.Add(new HomepageAlbumModel() { Name = "Top rated", Albums = Helpers.Convert(repo.GetTopRated(ALBUMS_IN_CATEGORY)) }); models.Add(new HomepageAlbumModel() { Name = "Random", Albums = Helpers.Convert(repo.GetRandom(ALBUMS_IN_CATEGORY)) }); models.Add(new HomepageAlbumModel() { Name = "Biggest", Albums = Helpers.Convert(repo.GetBiggest(ALBUMS_IN_CATEGORY)) }); models.Add(new HomepageAlbumModel() { Name = "Recently commented", Albums = Helpers.Convert(repo.GetRecentlyCommented(ALBUMS_IN_CATEGORY)) }); models.Add(new HomepageAlbumModel() { Name = "Most commented", Albums = Helpers.Convert(repo.GetMostCommented(ALBUMS_IN_CATEGORY)) }); return View(models); }
public ActionResult Charts(ChartCategory? category) { const int maxAlbums = 4; HomepageAlbumModel model = null; AlbumRepository repo = new AlbumRepository(); @ViewBag.Category = MainCategory.Charts; category = category ?? ChartCategory.Popular; if (!Enum.IsDefined(typeof(ChartCategory), category)) category = ChartCategory.Popular; @ViewBag.Chart = category; switch (category) { case ChartCategory.Popular: { model = new HomepageAlbumModel() { Name = "Most popular", Albums = Helpers.Convert(repo.GetMostPopular(maxAlbums)) }; break; } case ChartCategory.Biggest: { model = new HomepageAlbumModel() { Name = "Biggest", Albums = Helpers.Convert(repo.GetBiggest(maxAlbums)) }; break; } case ChartCategory.MostComments: { model = new HomepageAlbumModel() { Name = "Most commented", Albums = Helpers.Convert(repo.GetMostCommented(maxAlbums)) }; break; } case ChartCategory.TopRated: { model = new HomepageAlbumModel() { Name = "Highest rated", Albums = Helpers.Convert(repo.GetTopRated(maxAlbums)) }; break; } } return View(model); }