private void Custom(object obj) { try { string temp = ((CheckBox)obj).Tag.ToString(); Caters.Model.Factory.CustomizesFactory customizefood = null; AddCustomizationToFood(customizefood, Foods, temp); CustomMessage(); } catch (Exception ex) { throw; } }
public void AddCustomizationToFood(Caters.Model.Factory.CustomizesFactory customizefood, ObservableCollection <Caters.Model.Common.Food> Foods, string compare) { if (SelectedIndex <= 0) { MessageBox.Show("Select the Item number to be cosutomized from drop down"); ResetSelection(); return; } try { if (Foods.Count < SelectedIndex) { return; } Caters.Model.Common.Food tempfood = Foods.Where(p => p.TypeOfFood.Contains(compare as string)).ToList()[SelectedIndex - 1]; foreach (var item in PizzaSandwitchCustomOptions) { if (item.Name.Contains("Brown")) { if (item.IsSelect) { if (!tempfood.Customization.OfType <Caters.Model.Customize.BrownBread>().Any()) { customizefood = new Model.Factory.CustomizeFactory.BrownBreadFactory(); tempfood.Customization.Add(customizefood.GetCutomize()); } } else { if (tempfood.Customization.OfType <Caters.Model.Customize.BrownBread>().Any()) { tempfood.Customization.Remove(tempfood.Customization.OfType <Caters.Model.Customize.BrownBread>().First()); } } } else if (item.Name.Contains("Softy")) { if (item.IsSelect) { if (!tempfood.Customization.OfType <Caters.Model.Customize.Softy>().Any()) { customizefood = new Model.Factory.CustomizeFactory.SoftyFactory(); tempfood.Customization.Add(customizefood.GetCutomize()); } } else { if (tempfood.Customization.OfType <Caters.Model.Customize.Softy>().Any()) { tempfood.Customization.Remove(tempfood.Customization.OfType <Caters.Model.Customize.Softy>().First()); } } } else if (item.Name.Contains("Cream")) { if (item.IsSelect) { if (!tempfood.Customization.OfType <Caters.Model.Customize.Cream>().Any()) { customizefood = new Model.Factory.CustomizeFactory.CreamFactory(); tempfood.Customization.Add(customizefood.GetCutomize()); } } else { if (tempfood.Customization.OfType <Caters.Model.Customize.Cream>().Any()) { tempfood.Customization.Remove(tempfood.Customization.OfType <Caters.Model.Customize.Cream>().First()); } } } else if (item.Name.Contains("White")) { if (item.IsSelect) { if (!tempfood.Customization.OfType <Caters.Model.Customize.WhiteBread>().Any()) { customizefood = new Model.Factory.CustomizeFactory.WhiteBreadFactory(); tempfood.Customization.Add(customizefood.GetCutomize()); } } else { if (tempfood.Customization.OfType <Caters.Model.Customize.WhiteBread>().Any()) { tempfood.Customization.Remove(tempfood.Customization.OfType <Caters.Model.Customize.WhiteBread>().First()); } } } else if (item.Name.Contains("Cheese")) { if (item.IsSelect) { if (!tempfood.Customization.OfType <Caters.Model.Customize.CheeseTopping>().Any()) { customizefood = new Model.Factory.CustomizeFactory.CheeseToppingFactory(); tempfood.Customization.Add(customizefood.GetCutomize()); } } else { if (tempfood.Customization.OfType <Caters.Model.Customize.CheeseTopping>().Any()) { tempfood.Customization.Remove(tempfood.Customization.OfType <Caters.Model.Customize.CheeseTopping>().First()); } } } else if (item.Name.Contains("Sauce")) { if (item.IsSelect) { if (!tempfood.Customization.OfType <Caters.Model.Customize.SauceTopping>().Any()) { customizefood = new Model.Factory.CustomizeFactory.SauceToppingFactory(); tempfood.Customization.Add(customizefood.GetCutomize()); } } else { if (tempfood.Customization.OfType <Caters.Model.Customize.SauceTopping>().Any()) { tempfood.Customization.Remove(tempfood.Customization.OfType <Caters.Model.Customize.SauceTopping>().First()); } } } } Order.Foods = Foods.ToList(); } catch (Exception ex) { throw ex; } }