public void CreateoOrderrAddItemsToOrder(MenuItemOrder item) { if (CurrentOrder == null) { CurrentOrder = new Order(); } Console.WriteLine(JsonSerializer.Serialize(item)); CurrentOrder.MenuItemsOrder.Add(item); }
public void AddItemToOrder(MenuItemOrderInputModel item, string userId) { if (item.IsIdEmpty()) { throw new ArgumentException(); } var order = this.repo.All() .Where(uo => uo.UserId.Equals(userId)) .Select(uo => uo.Order) .SingleOrDefault(); var menuItemOrder = new MenuItemOrder() { MenuItemPriceId = item.Id, UserId = userId, }; order.MenuItemOrders.Add(menuItemOrder); this.repo.Save(); }