public ActionResult checkout(Order order) { RedirectToAction("viewShoppingCart"); if (order.id != 0) { return View(showOrder(order)); } ViewBag.Empty = false; ShoppingCart cart = getCart(); if (cart == null) { ViewBag.Empty = true; return View(); } var orderDB = new DBOrder(); var OrderId = orderDB.checkout(cart); var returnCustomer= (Customer) Session["LoggedInUser"]; returnCustomer.shoppingcart = new ShoppingCart(returnCustomer.id); Session["LoggedInUser"] = returnCustomer; return View(new BillingDocument() { customer = returnCustomer, shoppingcart = cart, order = new Order() { id = OrderId, customerid = returnCustomer.id, orderdate = DateTime.Now }, sum = cart.sum, exmva = cart.sum * 0.8, mva = cart.sum * 0.2 }); }
private BillingDocument showOrder(Order id) { var orderDB = new DBOrder(); List<OrderLine> list = orderDB.getOrder(id.id); List<ShoppingCartItem> cartItems = new List<ShoppingCartItem>(); var cartSum = 0; foreach(var item in list){ cartItems.Add(new ShoppingCartItem(item.product, item.quantity)); cartSum += item.product.price * item.quantity; }; var cart = new ShoppingCart(id.customerid) { shoppingCartItems = cartItems, sum = cartSum }; var billingDoc = new BillingDocument(){ order = id, customer = (Customer) Session["LoggedInUser"], shoppingcart = cart, sum = cart.sum, exmva = cart.sum * 0.8, mva = cart.sum * 0.2 }; return billingDoc; }