public List <RMenuGroupModifierVM> GetMenuItemModifiers(RMenuItemVM model) { List <RMenuGroupModifierVM> GroupModeifierVMList = new List <RMenuGroupModifierVM>(); List <RMenuModifierPrice> ModifierPriceList = new List <RMenuModifierPrice>(); //Add menu item modifier Price list if (model.MenuItem.ModifierPriceIDs != null && model.MenuItem.ModifierPriceIDs.Count > 0) { foreach (var modifierPrice in model.MenuItem.ModifierPriceIDs) { var pricemodel = Shared.APIs.IRestaurant.GetModifierPrice(model.LocationId, model.MenuId, model.MenuItem.ID, modifierPrice); ModifierPriceList.Add(pricemodel); } } //Filter and add menu item modifiers if (model.MenuItem.ModifierGroupIDs != null && model.MenuItem.ModifierGroupIDs.Count > 0) { foreach (var modifier in model.MenuItem.ModifierGroupIDs) { RMenuGroupModifierVM GroupModeifierVM = new RMenuGroupModifierVM(); List <RMenuModifierVM> menuModifierVMList = new List <RMenuModifierVM>(); GroupModeifierVM.MenuModifierGroup = Shared.APIs.IRestaurant.GetMenuModifierGroup(model.LocationId, model.MenuId, modifier); var GroupModifiers = Shared.APIs.IRestaurant.GetMenuModifiers(model.LocationId, model.MenuId, modifier); foreach (var GroupModifier in GroupModifiers) { RMenuModifierVM menuModifierVM = new RMenuModifierVM(); menuModifierVM.MenuModifier = GroupModifier; menuModifierVM.IsSelected = GroupModifier.ApplyByDefault; menuModifierVM.SubMenuModifiers = new List <RMenuModifierVM>(); menuModifierVM.SubMenuModifierGroups = new List <RMenuModifierGroup>(); foreach (var submodifierGroup in GroupModifier.SubmodifierGroupIDs) { menuModifierVM.SubMenuModifierGroups.Add(Shared.APIs.IRestaurant.GetMenuModifierGroup(model.LocationId, model.MenuId, submodifierGroup)); menuModifierVM.SubMenuModifiers.AddRange(Shared.APIs.IRestaurant.GetMenuModifiers(model.LocationId, model.MenuId, submodifierGroup).Select(s => new RMenuModifierVM { MenuModifier = s, IsSelected = s.ApplyByDefault })); } var modifierPrice = ModifierPriceList.Where(w => w.ModifierID == GroupModifier.ID).FirstOrDefault(); if (modifierPrice != null) { menuModifierVM.ModifierPrice = modifierPrice.Price; menuModifierVM.Additive = modifierPrice.Additive; } else { menuModifierVM.ModifierPrice = GroupModifier.Price; } menuModifierVMList.Add(menuModifierVM); } //Add menu item modifiers GroupModeifierVM.MenuModifiers = menuModifierVMList; GroupModeifierVMList.Add(GroupModeifierVM); } } return(GroupModeifierVMList); }
public MenuItemVM MapMenuItemBasePrice(RMenuItemVM model) { List <decimal?> PriceList = new List <decimal?>(); MenuItemVM menuItemVM = new MenuItemVM { MenuItemOriginalPrice = model.MenuItem.BasePrice }; if (model.MenuItem.BasePrice == null) { if (model.MenuItem.ModifierPriceIDs != null && model.MenuItem.ModifierPriceIDs.Count > 0) { foreach (var modifierPrice in model.MenuItem.ModifierPriceIDs) { var pricemodel = Shared.APIs.IRestaurant.GetModifierPrice(model.LocationId, model.MenuId, model.MenuItem.ID, modifierPrice); PriceList.Add(pricemodel.Price); } model.MenuItem.BasePrice = PriceList.Where(f => f > 0).Min(); } } menuItemVM.MenuItem = model.MenuItem; return(menuItemVM); }