/// <summary> /// Creates new details of an order using the price and the amoung /// </summary> /// <param name="orderNum"></param> /// <param name="itemNum"></param> /// <param name="amount"></param> /// <returns></returns> public decimal NewOrderDetail(int orderNum, int itemNum, int amount) { Aorder getorder = context.Aorders.FirstOrDefault(o => o.OrderId == orderNum); List <InventoryDetail> inventory = context.InventoryDetails.ToList(); inventory.Find(i => getorder.StoreId == i.StoreId && itemNum == i.ItemId).Amount -= amount; context.InventoryDetails.Update(inventory.Find(i => getorder.StoreId == i.StoreId && itemNum == i.ItemId)); context.SaveChanges(); AorderDetail newDetail = new AorderDetail() { Id = ((context.AorderDetails.Any(o => o.Id == 1)) ? context.AorderDetails.Max(o => o.Id) + 1 : 1), OrderId = orderNum, ItemId = itemNum, Total = Convert.ToDecimal(amount) }; context.AorderDetails.Add(newDetail); context.SaveChanges(); return(0.0m); }
public AorderDetail AddOrderDetail(AorderDetail newOrderDetail) { orderDetails.Add(newOrderDetail); return(newOrderDetail); }
public IActionResult addOrderDetail(AorderDetail newOrderDetail) { orderDetails.AddOrderDetail(newOrderDetail); return(Ok()); }