public void Load(bool isDeliveryOrder) { _isDeliveryOrder = isDeliveryOrder; // CartItem -> Product -> DealItem Product = new BxDealItem(_dealId); if (_dealId > 0) { Product.Load(_isDeliveryOrder); } // CartItem -> Product -> DealItem -> (*) MenuItem if (_menuItemId > 0) { var item = new BxMenuItem(_menuItemId) {}; item.Load(_isDeliveryOrder); //item.Name = "asd"; if (!string.IsNullOrWhiteSpace(item.Name) && !Product.Contains(item)) { Product.Items.Add(item); } } // CartItem -> Product -> DealItem -> (*) MenuItem -> (*) SubMenuItem if (_subMenuItemId != 0) { var subItem = new SubMenuItem(_menuItemId, _subMenuItemId); subItem.Load(_isDeliveryOrder); if (!string.IsNullOrWhiteSpace(subItem.Name) && !Product.GetMenuItem(_menuItemId).Contains(subItem)) { Product.GetMenuItem(_menuItemId).Items.Add(subItem); if ((subItem.UnitPrice > 0)) { Product.GetMenuItem(_menuItemId).UnitPrice = subItem.UnitPrice; } } } // Is this add dressing? // CartItem -> Product -> DealItem -> (*) MenuItem -> (*) Dressing if (_dressingId != 0) { var dressing = new MenuDressing(_menuItemId, _dressingId); dressing.Load(_isDeliveryOrder); if (!Product.GetMenuItem(_menuItemId).Contains(dressing)) { Product.Items.Add(dressing); } } // Is this adding topping? // CartItem -> Product -> DealItem -> (*) MenuItem -> (*) Topping if (_toppingId != 0) { var isExcluding = _toppingId < 0; var topping = new MenuTopping(_menuItemId, _subMenuItemId, Math.Abs(_toppingId)); topping.Load(_isDeliveryOrder); if (!string.IsNullOrWhiteSpace(topping.Name) && !Product.GetMenuItem(_menuItemId).Contains(topping)) { if (isExcluding) { topping.Name = "NOT " + topping.Name; } Product.Items.Add(topping); } } }
public void AddMenuItemOnToExistedDeal(string cartItemId, int menuItemId, int subMenuItemId) { var cartItem = Items.FirstOrDefault(i => i.CartId == cartItemId); if (cartItem == null) return; var subItem = new BxMenuItem(menuItemId) { }; subItem.Load(IsDeliveryOrder); if (!string.IsNullOrWhiteSpace(subItem.Name) && !cartItem.Product.Contains(subItem)) { cartItem.Product.Items.Add(subItem); } if (subMenuItemId > 0) { var grandSubItem = new SubMenuItem(menuItemId, subMenuItemId); grandSubItem.Load(IsDeliveryOrder); if (!string.IsNullOrWhiteSpace(grandSubItem.Name) && !cartItem.Product.GetMenuItem(menuItemId).Contains(grandSubItem)) { cartItem.Product.GetMenuItem(menuItemId).Items.Add(grandSubItem); if ((grandSubItem.UnitPrice > 0)) { cartItem.Product.GetMenuItem(menuItemId).UnitPrice = grandSubItem.UnitPrice; } } } }