public ActionResult DeleteConfirmed(int?id)
        {
            Menu menu = db.Menus.Find(id);

            db.Menus.Remove(menu);
            foreach (var item in db.Reviews)
            {
                if (item.MenuID == menu.MenuID)
                {
                    db.Reviews.Remove(item);
                }
            }
            using (PersonalMenuEntities db = new PersonalMenuEntities())
            {
                foreach (var item in db.PersonalMenus)
                {
                    if (item.MenuID == menu.MenuID)
                    {
                        db.PersonalMenus.Remove(item);
                    }
                }
                db.SaveChanges();
            }
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public ActionResult AddFavourite(Menu menu)
        {
            if (User.Identity.IsAuthenticated)
            {
                PersonalMenu personalMenu = new PersonalMenu();

                string id = User.Identity.GetUserId();

                using (PersonalMenuEntities db = new PersonalMenuEntities())
                {
                    personalMenu.Id     = id;
                    personalMenu.MenuID = menu.MenuID;
                    db.PersonalMenus.Add(personalMenu);
                    db.SaveChanges();
                }


                AspNetUser aspNetUser = db.AspNetUsers.Find(id);
                // aspNetUser.Menus.Add(menu);

                return(Redirect(Request.UrlReferrer.ToString()));

                // personalMenu.MenuID;
            }
            else
            {
                return(RedirectToAction("Index", "Home"));
            }
        }
Exemple #3
0
        //Delete Menu
        public ActionResult DeleteMenu()
        {
            using (PersonalMenuEntities db = new PersonalMenuEntities())
            {
                string userid           = User.Identity.GetUserId();
                List <PersonalMenu> tmp =
                    db.PersonalMenus.Where(x => x.Id.Equals(userid) && x.MenuID.Equals(menutmp.MenuID)).ToList();
                db.PersonalMenus.RemoveRange(tmp);
                db.SaveChanges();
            }

            return(RedirectToAction("Create", "Reviews", menutmp));
        }