예제 #1
0
        public ActionResult Create(User user)
        {
            if (ModelState.IsValid)
            {
                db.Users.Add(user);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(user);
        }
예제 #2
0
        public ActionResult LogIn(User user)
        {
            var userExist = (from u in db.Users
                                where u.UserName == user.UserName && u.Password == user.Password
                                select u).Count();

            if (userExist > 0)
            {
                Session["userName"] = user.UserName;
                Session["userLogged"] = true;

                return RedirectToAction("Index", "News");
            }
            else {
                ViewBag.errorCredenciales = "Datos Erroneos";
            }

            return View();
        }