Beispiel #1
0
        public ActionResult SignUp(string Item, string Store, string Cost)
        {
            if (string.IsNullOrEmpty(Item) || string.IsNullOrEmpty(Store))
            {
                return(View("~/Views/Shared/Error1.cshtml"));
            }

            else
            {
                using (ShoppingEntities1 db = new ShoppingEntities1())
                {
                    var signup = new ShoppingList();
                    signup.Item  = Item;
                    signup.Store = Store;
                    signup.Cost  = Cost;

                    //ViewBag.Item = signup.Item;
                    //ViewBag.Store = signup.Store;
                    //ViewBag.Cost = signup.Cost;

                    db.ShoppingLists.Add(signup);
                    db.SaveChanges();
                }
                return(RedirectToAction("Index"));
            }
        }
Beispiel #2
0
 public ActionResult Unsubscribe(int Id)
 {
     using (ShoppingEntities1 db = new ShoppingEntities1())
     {
         var signup = db.ShoppingLists.Find(Id);
         signup.Removed = DateTime.Now;
         db.SaveChanges();
     }
     return(RedirectToAction("Index"));
 }
Beispiel #3
0
        //private ShoppingEntities1 db = new ShoppingEntities1();

        public ActionResult Index()
        {
            using (ShoppingEntities1 db = new ShoppingEntities1())
            {
                var signups = (from c in db.ShoppingLists
                               where c.Removed == null
                               select c).ToList();
                var signupVms = new List <SignupVm>();
                foreach (var signup in signups)
                {
                    var signupVm = new SignupVm();
                    signupVm.Id    = signup.Id;
                    signupVm.Item  = signup.Item;
                    signupVm.Store = signup.Store;
                    signupVm.Cost  = signup.Cost;

                    signupVms.Add(signupVm);
                }
                return(View(signupVms));
            }
        }