public ActionResult InserirUsuario(Login login) { LoginRepositorie db = new LoginRepositorie(); login.Password = Encrypt(login.Password); db.CriarUsuario(login); return RedirectToAction("Login"); }
public void CriarUsuario(Login login) { EnglishGo_Context db = new EnglishGo_Context(); db.Login.Add(login); db.SaveChanges(); }
public bool Validar(ref Login login) { using (EnglishGo_Context db = new EnglishGo_Context()) { string user = login.User; string password = login.Password; var contas = db.Login.Where(log => log.User == user && log.Password == password); if (contas.Count() > 0) { login = contas.First(); return true; } else return false; } }
public ActionResult Login(Login conta) { LoginRepositorie db = new LoginRepositorie(); conta.Password = Encrypt(conta.Password); if (db.Validar(ref conta)) { FormsAuthentication.SetAuthCookie(conta.User, true); string returnURL = Request.QueryString["ReturnURL"]; if (returnURL != null) { return Redirect(returnURL); } else { return RedirectToAction("Escola", "Listar"); } } ViewBag.Mensagem = "Login e/ou senha inválido(s)"; return View(); }