1
Vote

music store example error in creating shopping cart index view

description

when creating index view of shopping cart in music store example error is
The model item passed into the dictionary is of type 'Music.ViewModels.ShoppingCartViewModel', but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable`1[Music.ViewModels.ShoppingCartViewModel]'.
the view model is :
public class ShoppingCartViewModel
{
public List<Cart> CartItems { get; set; }
public decimal CartTotal { get; set; }
}
in shopping cart controller:
public ActionResult Index()
    {
        var cart = ShoppingCart.GetCart(this.HttpContext);
        // Set up our ViewModel
        var viewModel = new ShoppingCartViewModel
        {
            CartItems = cart.GetCartItems(),
            CartTotal = cart.GetTotal()
        };
        // Return the view
        return View(viewModel);

    }
is anythin need to modify in viewmodel.please reply me.

comments