public async Task <IActionResult> PostOrder(OrderWithCustomerViewModel orderWithCustomer) { var ids = servicesCart.GetCartItems(); var shopItems = shopCartRep.GetShopCartItems(ids); if (!orderRep.CheckProductsInStock(shopItems)) { return(RedirectToAction("ShopCart", "Index", new { message = "К сожалению на складе нет товаров в таком количестве" })); } await orderRep.CreateOrderAsync(orderWithCustomer.User, shopItems, orderWithCustomer.Order); servicesCart.Drop(); return(RedirectToAction("VariousInf", "Order", new { inf = "Заказ успешно создан" })); }
public IActionResult CreateOrder() { var user = servicesUser.GetUser(); var ids = servicesCart.GetCartItems(); var shopItems = shopCartRep.GetShopCartItems(ids); if (!orderRep.CheckProductsInStock(shopItems)) { return(RedirectToAction("Index", "ShopCart", new { message = "К сожалению на складе нет товаров в таком количестве" })); } var orderWithCustomer = new OrderWithCustomerViewModel(); orderWithCustomer.User = user; return(View(orderWithCustomer)); }