public ActionResult Login(User user, string returnUrl)
        {
            if (!ModelState.IsValid)
            {
                return View(user);
            }

            // This doesn't count login failures towards account lockout
            // To enable password failures to trigger account lockout, change to shouldLockout: true
            using (var db = new Repository())
            {
                var hasUser = db.Context.User.Where(x => x.Email == user.Email && x.Password == user.Password).FirstOrDefault();
                if (hasUser != null)
                {
                    Session["user"] = hasUser;
                    return RedirectToLocal(returnUrl);
                }
                else
                {
                    ModelState.AddModelError("", "Invalid login attempt.");
                    return View(user);
                }
            }
        }
        public ActionResult Register(User model)
        {
            if (ModelState.IsValid)
            {
                using (var db = new Repository())
                {
                    var hasUser = db.Context.User.Where(x => x.Email == model.Email).FirstOrDefault();
                    if (hasUser == null)
                    {
                        db.Add(model);
                        db.Save();
                        Session["user"] = model;
                        return RedirectToAction("Index", "Home");
                    }

                    else
                    {
                        ModelState.AddModelError("", "Invalid login attempt.");
                        return View(model);
                    }

                }
            }
            else
            {
                ModelState.AddModelError("", "Invalid login attempt.");
                return View(model);
            }

        }