//public ActionResult Index() //{ // // Get most popular albums // var albums = GetTopSellingAlbums(5); // return View(albums); //} //public ActionResult Index() //{ // // Get most popular albums // var albums = new SqlAlbumRepository().GetTopSellingAlbums(5); // return View(albums); //} public ActionResult Index() { // Get most popular albums var albums = new CachedAlbumRepository().GetTopSellingAlbums(5); return(View(albums)); }
// // GET: /Store/AddToCart/5 //public ActionResult AddToCart(int id) //{ // // Retrieve the album from the database // var addedAlbum = storeDB.Albums // .Single(album => album.AlbumId == id); // // Add it to the shopping cart // var cart = ShoppingCart.GetCart(this.HttpContext); // cart.AddToCart(addedAlbum); // // Go back to the main store page for more shopping // return RedirectToAction("Index"); //} public ActionResult AddToCart(int id) { // Retrieve the album from the database var addedAlbum = new CachedAlbumRepository().GetById(id); // Add it to the shopping cart var cart = ShoppingCart.GetCart(this.HttpContext); cart.AddToCart(addedAlbum); // Go back to the main store page for more shopping return(RedirectToAction("Index")); }