Beispiel #1
0
        public async Task <IActionResult> CreateOrder(CreateOrderModel model)
        {
            if (ModelState.IsValid)
            {
                //address is created
                Address address = new Address()
                {
                    FullName = model.FullName,
                    Street   = model.Street,
                    City     = model.City,
                    Zip      = model.Zip
                };

                var user = await _userManager.GetUserAsync(User);

                //order with pending status is created
                Order order = new Order()
                {
                    Email       = user.Email,
                    Address     = address,
                    TotalAmount = _cartService.CountTotalAmount(user.Email),
                    //Items = _cartService.GetAllItemsFromCart(user.Email),
                    OrderStatusId = _orderService.GetOrderStatusByName("Pending")
                };

                int orderId = _orderService.AddOrderAndAddress(order);
                _cartService.SetOrderId(user.Email, orderId);

                return(RedirectToAction("Payment", "Order", new { orderId }));
            }

            return(View(model));
        }
Beispiel #2
0
        public IActionResult Order(int orderId)
        {
            Order order = _orderService.GetOrderById(orderId);

            return(View(order));
        }