public void PlaceOrder(OrderPlacementViewModel placeOrder) { var order = _mapper.MapViewModelToOrder(placeOrder, _countryRepository, _productRepository); order.OrderValue = order.OrderLines.Sum(x => x.Value); _orderRepository.PlaceOrder(order); }
public ActionResult PlaceOrder(OrderPlacementViewModel placeOrder) { placeOrder.ShoppingCart = Session["cart"] as ShoppingCartViewModel; Session["cart"] = null; _orderPlacer.PlaceOrder(placeOrder); return(RedirectToAction("Index")); }
public Order MapViewModelToOrder(OrderPlacementViewModel placeOrder, CountryRepository countryRepository, ProductRepository productRepository) { var order = new Order {BillingAddress = MapViewModelToAddress(placeOrder.BillingAddress, countryRepository)}; order.ShipToAddress = placeOrder.UseShipToAddress ? MapViewModelToAddress(placeOrder.ShipToAddress, countryRepository) : order.BillingAddress; order.PaymentMethod = placeOrder.ChosenPaymentMethod; order.OrderLines = MapShoppingCartToOrderLines(placeOrder.ShoppingCart, productRepository); return order; }
public OrderPlacementViewModel GetOrderPlacement() { var order = new OrderPlacementViewModel(); var countries = GetCountries(); order.Products = GetProducts(); order.ShoppingCart = GetEmptyShoppingCart(); order.ShipToAddress = new AddressViewModel { Countries = new SelectList(countries, "IsoCode", "DisplayName") }; order.BillingAddress = new AddressViewModel { Countries = new SelectList(countries, "IsoCode", "DisplayName") }; order.PaymentMethods = GetPaymentMethods(); return(order); }
public HomeController() { _orderPlacer = new OrderPlacementManager(); _orderLister = new OrderListManager(); _order = _orderPlacer.GetOrderPlacement(); }