Esempio n. 1
0
        public ActionResult Index()
        {
            //var albums = db.Albums.Include(a => a.Genre).Include(a => a.Artist);
            List <Album> albums = _albums.Get().Include(a => a.Genre).Include(a => a.Artist).ToList();

            return(View(albums));
        }
        //
        // GET: /Store/Details/5
        public ActionResult Details(int id)
        {
            //var album = storeDB.Albums.Find(id);
            var album = _albums.Get(a => a.AlbumId == id)
                        .Include(a => a.Genre)
                        .Include(a => a.Artist)
                        .SingleOrDefault();

            return(View(album));
        }
        //
        // GET: /Store/AddToCart/5
        public ActionResult AddToCart(int id)
        {
            // Retrieve the album from the database
            //var addedAlbum = storeDB.Albums
            //    .Single(album => album.AlbumId == id);
            var addedAlbum = _albums.Get(album => album.AlbumId == id).Single();

            // Add it to the shopping cart
            var cart = _shoppingCartFactory.GetCart(this.HttpContext);

            cart.AddToCart(addedAlbum);

            // Go back to the main store page for more shopping
            return(RedirectToAction("Index"));
        }