public ActionResult CheckOut() { var currentUserId = this.User.Identity.GetUserId(); if (this._service.ContainsItemsNotInStock(currentUserId)) { return(RedirectToAction("ShoppingCart", "Purchase")); } FinalCheckoutViewModel finalItemsPrice = this._service.CalculatePriceWithoutShipment(currentUserId); return(this.View(finalItemsPrice)); }
public FinalCheckoutViewModel CalculatePriceWithoutShipment(string currentUserId) { var customer = this.Context.Customers.First(c => c.User.Id == currentUserId); var cart = this.Context.ShoppingCarts.First(c => c.Customer.Id == currentUserId); var finalCheckoutVm = new FinalCheckoutViewModel { CurrentCustomerBalance = customer.Credits }; foreach (var product in cart.Products) { finalCheckoutVm.FinalPrice += this.CalculateFinalPrice(product.Discount, product.Price); } return(finalCheckoutVm); }