public PizzaL(string C, string Si, string Sa, string FC, string SC) { SizeL s = new SizeL(); CrustL c = new CrustL(); SauceL sa = new SauceL(); CheeseL ch = new CheeseL(); Crust = c.FindCrustByName(C); Size = s.FindSizeByName(Si); Sauce = sa.FindSauceByName(Sa); Cheese1 = ch.FindCheeseByName(FC); Cheese2 = ch.FindCheeseByName(SC); Cost = GetTotalCost(C, Si); if (!CheckTotalCost()) { throw new Exception("The total cost is over $1,000!!!"); } EFData ef = new EFData(); ef.AddPizza(Crust, Size, Sauce, Cheese1, Cheese2, Cost); ef.AddPizzaOrder(); c.ClearSelected(); s.ClearSelected(); sa.ClearSelected(); ch.ClearSelected(); }
public void ClearSelected() { EFData ed = new EFData(); foreach (var item in ed.ReadSauce()) { item.Selected = false; } }
public int GetToppingCount() { EFData ed = new EFData(); int i = 0; return(i); }
public void GetLocationDough(string site) { EFData ef = new EFData(); foreach (var item in ef.ReadLocation()) { if (item.Name == site) { Dough = double.Parse(item.dough.ToString()); } } }
public int FindLocationByName(string itemName) { EFData ed = new EFData(); foreach (var item in ed.ReadLocation()) { if (item.Name == itemName) { return(item.LocationId); } } throw new ArgumentNullException("No Location Selected"); }
public string FindSelectedSauce() { EFData ed = new EFData(); foreach (var item in ed.ReadSauce()) { if (item.Selected) { return(item.Name); } } throw new ArgumentNullException("No Size Selected"); }
public bool CheckIfAnyPizzas() { EFData ef = new EFData(); foreach (var item in ef.ReadPizzaOrder()) { if (item.Order == ef.ReadOrder().Count() + 1) { return(true); } } return(false); }
public double GetCrustCost(string itemName) { EFData ed = new EFData(); foreach (var item in ed.ReadCrust()) { if (item.Name == itemName) { return(double.Parse(item.Price.ToString())); } } throw new ArgumentNullException("No Size Added"); }
public void FillToppingTable(List <string> tl) { ToppingL t = new ToppingL(); List <int> Topping = new List <int>(); foreach (string item in tl) { Topping.Add(t.FindToppingByName(item)); } EFData ef = new EFData(); ef.AddPizzaTopping(Topping); }
public string FindCrustByName(string itemName) { EFData ed = new EFData(); foreach (var item in ed.ReadCrust()) { if (item.Name == itemName) { item.Selected = true; return(item.Name); } } throw new ArgumentNullException("No Crust Selected"); }
public int FindToppingByName(string itemName) { EFData ed = new EFData(); foreach (var item in ed.ReadTopping()) { if (item.Name == itemName) { item.Selected = true; return(item.ToppingId); } } throw new ArgumentNullException("No Topping Selected"); }
public static int FindIndexOfSelected() { EFData ed = new EFData(); int i = 1; foreach (var item in ed.ReadSauce()) { if (item.Selected) { return(i); } i++; } throw new ArgumentNullException("Couldn't find record"); }
public List <int> FindSelectedTopping() { EFData ed = new EFData(); List <int> toppingIndexList = new List <int>(); int i = 1; foreach (var item in ed.ReadTopping()) { if (item.Selected) { toppingIndexList.Add(i); } i++; } return(toppingIndexList); }
public OrderL(string x, string site) { LocationL location = new LocationL(); CustomerLocation = location.FindLocationByName(x); Site = location.FindLocationByName(site); TotalCost = GetTotalCost(); GetLocationDough(site); if (!CheckIfAnyPizzas()) { throw new Exception("Add a pizza will ya."); } CheckIfStockLeft(); EFData ef = new EFData(); ef.AddOrder(CustomerLocation, Site, TotalCost); }
public bool CheckIfStockLeft() { EFData ef = new EFData(); foreach (var item in ef.ReadPizzaOrder()) { if (item.Order == ef.ReadOrder().Count() + 1) { foreach (var item2 in ef.ReadPizza()) { if (item2.PizzaId == item.Pizza) { foreach (var item3 in ef.ReadCrust()) { if (item2.Crust == item3.Name) { if (item3.Dough > decimal.Parse(Dough.ToString())) { throw new Exception("Dough Out of Stock"); } } } foreach (var item3 in ef.ReadSize()) { if (item2.Size == item3.Name) { if (item3.Dough > decimal.Parse(Dough.ToString())) { throw new Exception("Dough Out of Stock"); } } } foreach (var item3 in ef.ReadSauce()) { if (item2.Crust == item3.Name) { if (item3.Stock < decimal.Parse(5.1.ToString()) && item3.Name != "No Sauce") { throw new Exception("Sauce Out of Stock"); } } } foreach (var item3 in ef.ReadCheese()) { if (item2.FirstCheese == item3.Name) { if (item3.Stock < decimal.Parse(2.3.ToString()) && item3.Name != "No Cheese") { throw new Exception("Cheese Out of Stock"); } } if (item2.SecondCheese == item3.Name && item3.Name != "No Cheese") { if (item3.Stock < decimal.Parse(2.3.ToString())) { throw new Exception("Cheese Out of Stock"); } } } foreach (var item3 in ef.ReadPizzaTopping()) { if (item3.Pizza == item2.PizzaId) { foreach (var item4 in ef.ReadTopping()) { if (item3.Topping == item4.ToppingId) { if (item4.Stock < decimal.Parse(1.21.ToString())) { throw new Exception("Toppings Out of Stock"); } } } } } } } } } return(true); }
public double GetTotalCost() { EFData ef = new EFData(); return(ef.GetTotalCost(ef.ReadOrder().Count + 1)); }