Esempio n. 1
0
        public ActionResult DeletePizza(int id)
        {
            var _db       = new dat.PizzaStoreDbContext();
            var datapizza = _db.Pizza.Where(p => p.PizzaId == id).FirstOrDefault();

            datapizza.Active = false;
            _db.SaveChanges();
            return(OrderMenu());
        }
Esempio n. 2
0
        public ActionResult ThankYou()
        {
            dat.PizzaStoreDbContext _db = new dat.PizzaStoreDbContext();
            var orderID   = HttpContext.Session.GetInt32("orderID");
            var dataOrder = _db.Order.Where(o => o.OrderId == orderID).FirstOrDefault();

            dataOrder.TimeStamp = DateTime.Now;
            dataOrder.Voidable  = false;
            _db.SaveChanges();
            return(View("ThankYou"));
        }
Esempio n. 3
0
        // POST: Pizza/Create
        public ActionResult Update(PizzaViewModel pizzaview)
        {
            var pizzaID = HttpContext.Session.GetInt32("pizzaID");

            if (pizzaview.ToppingIDArray != null)
            {
                foreach (var top in pizzaview.ToppingIDArray)
                {
                    if (top != 0)
                    {
                        var pipair = new dat.PizzaIngredient()
                        {
                            PizzaId = pizzaID
                            ,
                            IngredientId = (short)top
                        };
                        _db.PizzaIngredient.Add(pipair);
                        _db.SaveChanges();
                    }
                }
            }


            var datapizza = _db.Pizza.Where(p => p.PizzaId == pizzaID).FirstOrDefault();

            if (pizzaview.CrustId != 0)
            {
                datapizza.CrustId = (byte)pizzaview.CrustId;
                _db.SaveChanges();
            }
            if (pizzaview.crustSize != 0)
            {
                datapizza.Size = (byte)pizzaview.crustSize;
                _db.SaveChanges();
            }
            datapizza.Price = (decimal)PizzaHelper.GetPriceByPizza(datapizza);
            _db.SaveChanges();

            return(RedirectToAction("OrderMenu", "Order"));
        }
Esempio n. 4
0
        public ActionResult DeleteTopping(int id)
        {
            var _db = new dat.PizzaStoreDbContext();
            int pid = (int)HttpContext.Session.GetInt32("pizzaID");

            var pipairs       = _db.PizzaIngredient.Where(pi => pi.PizzaId == pid).ToList();
            var targetTopping = pipairs.FirstOrDefault(pi => pi.IngredientId == id);

            targetTopping.Active = false;
            _db.SaveChanges();

            return(EditPizza(pid));
        }