Ejemplo n.º 1
0
        public IActionResult Checkout(Guid orderId, Guid productId)
        {
            var username = User.Identity.Name;

            orderId = _orderDetailsService.GetOrderId(username);
            _ordersService.CheckOut(orderId);
            ViewBag.Id = orderId;
            var prodId = _productsService.GetProduct(productId);

            ViewBag.prod = prodId;

            var productIds = _orderDetailsService.GetProductIds(orderId);

            _productsService.ReduceStock(productIds, orderId);

            TempData["feedback"] = "Order was completed successfully !";
            return(RedirectToAction("OrderDetails"));
        }
Ejemplo n.º 2
0
        public IActionResult checkOut()
        {
            var email = HttpContext.User.Identity.Name;

            try
            {
                _ordersService.CheckOut(email);

                TempData["feedback"] = "Check Out Succesfully";
                _productsLogger.LogInformation("Check Out Succeeded");
            }
            catch (Exception e)
            {
                TempData["warning"] = "Check Out Failed";
                _productsLogger.LogInformation(e.Message);
            }

            return(RedirectToAction("Index"));
        }