public void CreateOrderLine(int id, OrderLine orderline, string currentUser) { KitchenOrder k = new KitchenOrder(); k = Find(id); if (currentUser == k.User.Id && !k.Paid) { Consumption c = _consumptionManager.Find(orderline.ConsumptionId); if (c.Available && k.InProces == false) { OrderLine o = orderline; o.OrderId = id; double price = c.Price * orderline.NumberOfItems; o.PriceAmount += price; _OrderRepository.createOrderLine(orderline); k.TotalAmount += price; UpdateOrder(id, k); //update stock c.Stock -= orderline.NumberOfItems; _consumptionManager.Update(c.ConsumptionId, c); } } }
public ActionResult AddOrder(int id, OrderLine orderline) { _orderManager.CreateOrderLine(id, orderline, User.Identity.GetUserId()); return RedirectToAction("AddOrder", id); }