Esempio n. 1
0
        public ActionResult CreateOrder([FromBody] OrderViewModel orderViewModel)
        {
            var order = mapper.Map <OrderBO>(orderViewModel);

            orderService.CreateOrder(order);
            return(RedirectToAction("GetAllOrders", "Order"));
        }
Esempio n. 2
0
        public void SimulatePlaceOrder()
        {
            var products = _productRepository.GetAll(x => x.Stock > 0);

            foreach (var product in products)
            {
                _orderServices.CreateOrder(product.ProductCode, Quantity);
            }
        }
Esempio n. 3
0
 /// <inheritdoc />
 public void Execute(string[] commands)
 {
     if (commands.Length != 3)
     {
         Console.WriteLine("Command parameters not valid!");
         return;
     }
     _productCode = commands[1];
     int.TryParse(commands[2], out _quantity);
     _orderServices.CreateOrder(_productCode, _quantity);
 }
Esempio n. 4
0
        public async Task <IActionResult> Create(string foodId)
        {
            AppIdentityUser user = await _userManager.GetUserAsync(User);

            Food food = await _foodServices.GetFood(foodId);

            if (user != null && food != null)
            {
                OrderDetail order = await _orderServices.GetOrderToday(user.Id);

                if (order == null)
                {
                    if (await _orderServices.CreateOrder(food: food, user: user))
                    {
                        ViewBag.foodName = food.Name;
                        return(View("~/Views/Order/OrderSuccess.cshtml"));
                    }
                }
            }
            return(RedirectToAction(actionName: "Index", controllerName: "Home"));
        }
Esempio n. 5
0
 public ActionResult Checkout(Customer customer)
 {
     if (ModelState.IsValid)
     {
         var cartItem = Session["cart"];
         if (cartItem == null && customer == null)
         {
             return(View(customer));
         }
         var orderID = _orderServices.CreateOrder(cartItem as List <ProductInCart>, customer);
         return(RedirectToAction("OrderSuccessPage", "Success", new { orderID = orderID }));
     }
     return(View(customer));
 }