public ActionResult CreateOrder([FromBody] OrderViewModel orderViewModel) { var order = mapper.Map <OrderBO>(orderViewModel); orderService.CreateOrder(order); return(RedirectToAction("GetAllOrders", "Order")); }
public void SimulatePlaceOrder() { var products = _productRepository.GetAll(x => x.Stock > 0); foreach (var product in products) { _orderServices.CreateOrder(product.ProductCode, Quantity); } }
/// <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); }
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")); }
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)); }