public ActionResult Payment() { var applicationUserId = User.Identity.GetUserId(); var currentShippingAddress = _addressService.GetCustomerAddress(AddressType.Shipping, applicationUserId); var currentBillingAddress = _addressService.GetCustomerAddress(AddressType.Billing, applicationUserId); var model = new ReviewOrderViewModel() { CartItems = _cartService.GetCartItems(), CartTotal = string.Format("{0:F}", _cartService.GetTotal()), CartCount = _cartService.GetCount(), BillingAddress = Mapper.Map <AddressViewModel>(currentBillingAddress), ShippingAddress = Mapper.Map <AddressViewModel>(currentShippingAddress) }; return(View(model)); }
public ActionResult Payment(ReviewOrderViewModel reviewOrderViewModel) { if (reviewOrderViewModel.PromoCode != PromoCodeConstant.PromoCode) { ModelState.AddModelError("PromoCode", "Invalid Promo Code"); return(View(reviewOrderViewModel)); } var orderId = _orderService.ProcessOrder(_cartService, User.Identity.GetUserId()); if (orderId == 0) { ModelState.AddModelError("", "Order processing failed "); return(View(reviewOrderViewModel)); } return(RedirectToAction("Complete", new { id = orderId })); }