Esempio n. 1
0
        public async Task <IActionResult> AddressAndPayment([FromBody] Order order)
        {
            try
            {
                int orderId = await _checkoutService.AddressAndPayment(order);

                return(Ok(orderId));
            }
            catch (Exception ex)
            {
                _baseServise.Logger.Error("User {userName} Throw exception in checkout {Exception}.", order.Username, ex);
                throw;
            }
        }
        public ActionResult AddressAndPayment(FormCollection values)
        {
            var order = new Order();

            TryUpdateModel(order);
            var cart = ShoppingCart.GetCart(this.HttpContext);

            order.Total = cart.GetTotal();
            if (CheckOutService.AddressAndPayment(ref order, cart, User.Identity.Name, values["PromoCode"]))
            {
                //Process the order
                // var cart = ShoppingCart.GetCart(this.HttpContext);
                // cart.CreateOrder(order);
                return(RedirectToAction("Complete", new { id = order.OrderId }));
            }
            else
            {
                return(View(order));
            }
        }