Beispiel #1
0
        public ActionResult SearchByItem(string ItemName)
        {
            //1. Create an object from the ORM class in the .context file (this is what converts from database to object)
            Lab22CoffeeShopDB MyORM = new Lab22CoffeeShopDB();

            ViewBag.DisplayItems = MyORM.Items.Where(x => x.ItemName.Contains(ItemName)).toList();
            return(View(SearchByItem));
        }
Beispiel #2
0
        public ActionResult AddNewUser(User newUser)
        {
            //1: create object
            Lab22CoffeeShopDB MyORM = new Lab22CoffeeShopDB();



            {
                MyORM.Customers.Add(newUser); /* this addds the new customer. because we connected the tables, we will add data to the form in the correct place. Don't need to create individual objects; can add, remove, insert customers now */

                MyORM.SaveChanges();          /*MUST save changes. this moves the change to the database. otherwise you just added it to a list that didn't go beyond this file*/
            }
            return(View("AddNewUser"));
        }