예제 #1
0
        public bool MakeNewPizza(ref BLL.PizzaModel pz_m, List <BLL.IngredientModel> ingres)
        {
            try
            {
                DAL.Pizza pz = new DAL.Pizza();
                pz.Name         = pz_m.Name;
                pz.Price        = pz_m.Price;
                pz.PizzaType_ID = 2;

                db.Pizzas.Create(pz);
                db.Save();
                pz_m = new PizzaModel(db.Pizzas.GetLastRecord());

                foreach (var ingre in ingres)
                {
                    Receipt rc = new Receipt();
                    rc.Pizza_ID      = pz_m.ID;
                    rc.Ingredient_ID = ingre.ID;
                    db.Receipts.Create(rc);
                }
            }
            catch { }

            if (db.Save() > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #2
0
        public List <BLL.IngredientModel> GetIngreFromPizza(PizzaModel pizza)
        {
            var ingres = new List <IngredientModel>();
            List <ReceiptModel> rcs = this.GetAllReceipts();

            foreach (var i in rcs)
            {
                if (i.Pizza_ID == pizza.ID)
                {
                    ingres.Add(this.GetIngredient(i.Ingredient_ID));
                }
            }
            return(ingres);
        }