A question in CartController

Dec 28, 2010 at 3:52 AM


could you look at these codes:

        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);


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

My question is why we don't transfer the id value to the model directory, it converts to entity object first and querys the id in the model?

I think that is make sure the id is vaild, is it correct? Thanks!