Exemple #1
0
        /// <summary>
        /// Deletes a menu item from the database based on the parameter given.
        /// And the pizza that was in the menu
        /// </summary>
        /// <param name="menuid"></param>
        public void DeleteMenuItem(int menuid)
        {
            PizzaDb pizDb = new PizzaDb();

            string getPizzaCmd = "SELECT PizzaId FROM Menu WHERE id = " + menuid;
            string delCmd      = "DELETE FROM Menu WHERE id = " + menuid;

            int pizzaId = Int32.Parse(this.GetData(getPizzaCmd).Rows[0][0].ToString()); // Get pizza id

            // Delete From Menu
            this.DeleteData(delCmd);

            // Delete the pizza
            pizDb.DeletePizza(pizzaId);
        }
Exemple #2
0
        public List <PizzaMenu> GetMenu()
        {
            PizzaDb pizDb = new PizzaDb();

            string           menuCmd = "SELECT * FROM Menu";
            List <PizzaMenu> tmpMenu = new List <PizzaMenu>();

            DataTable menuDt = this.GetData(menuCmd);

            for (int i = 0; i < menuDt.Rows.Count; i++)
            {
                Pizza curPiz = pizDb.GetPizza(Int32.Parse(menuDt.Rows[i][1].ToString()));

                int menuid = Int32.Parse(menuDt.Rows[i][0].ToString());

                PizzaMenu pizMenu = new PizzaMenu(menuid, curPiz.Id, curPiz.Name, curPiz.Toppings);

                tmpMenu.Add(pizMenu);
            }

            return(tmpMenu);
        }