Exemple #1
0
        public ActionResult AddNewCoffee(Item NewItem)
        {
            GrandCircusDBEntities CoffeeDB = new GrandCircusDBEntities(); //orm

            CoffeeDB.Items.Add(NewItem);                                  // saves the new employee to the list
            CoffeeDB.SaveChanges();                                       // saves the new employee to the database
            return(RedirectToAction("About"));
        }
Exemple #2
0
        public ActionResult DeleteCoffee(string name)
        {
            GrandCircusDBEntities CoffeeDB = new GrandCircusDBEntities();
            Item i = CoffeeDB.Items.Find(name);

            CoffeeDB.Items.Remove(i);          // removes employee from the list
            CoffeeDB.SaveChanges();            // reflects the changes we did on list we have to the db
            return(RedirectToAction("About")); // go and execute action once you are done
        }
Exemple #3
0
        public ActionResult About()
        {
            GrandCircusDBEntities CoffeeDB = new GrandCircusDBEntities();
            List <Item>           AllItems = CoffeeDB.Items.ToList();

            ViewBag.CoffeeList = AllItems;
            ViewBag.Message    = "Add or delete coffee";
            return(View());
        }