// GET: Cart public ActionResult Index() { var cartId = new Helpers.CartHelpers().GetCartId(); var vm = new CartViewModel(); using (ShoppingCartActions usersShoppingCart = new ShoppingCartActions(cartId)) { var shoppingCartItems = usersShoppingCart.GetCartItems(); var cartItemsVM = Mapper.Map<List<CartItemViewModel>>(shoppingCartItems); vm.CartItems = cartItemsVM; vm.ItemsTotal = usersShoppingCart.GetCount(); vm.OrderTotal = usersShoppingCart.GetTotal(); } //var shoppingCartItems = db.ShoppingCartItems.Include(c => c.Product); return View(vm); }
// GET: Checkout public ActionResult Index() { var vm = new CheckoutViewModel(); using (ShoppingCartActions usersShoppingCart = new ShoppingCartActions(cartId)) { var shoppingCartItems = usersShoppingCart.GetCartItems(); var cartItemsVM = Mapper.Map<List<CartItemViewModel>>(shoppingCartItems); vm.CartItems = cartItemsVM; vm.OrderTotal = usersShoppingCart.GetTotal(); vm.ItemsTotal = usersShoppingCart.GetCount(); } // To make filling out the form faster for demo purposes, pre-fill the values: vm.Order = new OrderViewModel { // Important! Keep this property here! Total = vm.OrderTotal, // Prefill properties for convenience: FirstName = "Bob", LastName = "Loblaw", Address = "1313 Mockingbird Lane", City = "Virginia Beach", State = "VA", PostalCode = "23456", Country = "United States", Email = "*****@*****.**", NameOnCard = "Bob Loblaw", CreditCardType = "Visa", CreditCardNumber = "4111111111111111", ExpirationDate = "12/20", CCV = "987", SMSOptIn = true }; return View(vm); }
// GET: Checkout public ActionResult Index() { var vm = new CheckoutViewModel(); using (ShoppingCartActions usersShoppingCart = new ShoppingCartActions(cartId)) { var shoppingCartItems = usersShoppingCart.GetCartItems(); var cartItemsVM = Mapper.Map<List<CartItemViewModel>>(shoppingCartItems); vm.CartItems = cartItemsVM; vm.OrderTotal = usersShoppingCart.GetTotal(); vm.ItemsTotal = usersShoppingCart.GetCount(); } // To make filling out the form faster for demo purposes, pre-fill the values: vm.Order = new OrderViewModel { // Important! Keep this property here! Total = vm.OrderTotal, // Prefill properties for convenience: FirstName = "Brian", LastName = "Redmond", Address = "2349 Railroad Street", City = "Pittsburgh", State = "PA", PostalCode = "15222", Country = "United States", Email = "*****@*****.**", NameOnCard = "Brian Redmond", CreditCardType = "Visa", CreditCardNumber = "4111111111111111", ExpirationDate = "12/20", CCV = "987", SMSOptIn = true }; return View(vm); }