Beispiel #1
0
        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();
        }
Beispiel #2
0
        public void ClearSelected()
        {
            EFData ed = new EFData();

            foreach (var item in ed.ReadSauce())
            {
                item.Selected = false;
            }
        }
Beispiel #3
0
        public int GetToppingCount()
        {
            EFData ed = new EFData();

            int i = 0;


            return(i);
        }
Beispiel #4
0
        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());
                }
            }
        }
Beispiel #5
0
        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");
        }
Beispiel #6
0
        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");
        }
Beispiel #7
0
        public bool CheckIfAnyPizzas()
        {
            EFData ef = new EFData();

            foreach (var item in ef.ReadPizzaOrder())
            {
                if (item.Order == ef.ReadOrder().Count() + 1)
                {
                    return(true);
                }
            }

            return(false);
        }
Beispiel #8
0
        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");
        }
Beispiel #9
0
        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);
        }
Beispiel #10
0
        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");
        }
Beispiel #11
0
        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");
        }
Beispiel #12
0
        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");
        }
Beispiel #13
0
        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);
        }
Beispiel #14
0
        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);
        }
Beispiel #15
0
        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);
        }
Beispiel #16
0
        public double GetTotalCost()
        {
            EFData ef = new EFData();

            return(ef.GetTotalCost(ef.ReadOrder().Count + 1));
        }