public IActionResult Obter() { if (Request.Cookies["emailUsuario"] != null) { var email = Request.Cookies["emailUsuario"].ToString(); cl.UsuarioController ctlUsuario = new cl.UsuarioController(); return(Json(ctlUsuario.Obter(email))); } else { return(RedirectToAction("Logout", "Usuario", new { area = "Admin" })); } }
public IActionResult Alterar(IFormCollection form) { UsuarioViewModel u = new UsuarioViewModel(); u.Email = form["Email"].ToString().ToLower().Trim(); u.Nome = form["Nome"].ToString().Trim(); u.Telefone = form["Telefone"].ToString().Trim(); u.Cep = form["Cep"].ToString().Trim(); u.Cidade = form["Cidade"].ToString().Trim(); u.Estado = form["Estado"].ToString().Trim(); u.Endereco = form["Logradouro"].ToString().Trim(); u.Numero = form["Numero"].ToString().Trim(); u.Complemento = form["Complemento"].ToString().Trim(); u.Senha = form["Senha"].ToString().Trim(); u.DataCadastro = DateTime.Now; cl.UsuarioController ctlUsuario = new cl.UsuarioController(); return(Json(ctlUsuario.Alterar(u))); }
public IActionResult Autenticar(string email, string senha) { if (email.Trim().Length > 0 && senha.Trim().Length > 0) { cl.UsuarioController ctlUsuario = new cl.UsuarioController(); var u = ctlUsuario.Autenticar(email, senha); if (u != null) { CookieOptions ckOptions = new CookieOptions(); ckOptions.Expires = DateTime.Now.AddDays(30); Response.Cookies.Append("emailUsuario", email, ckOptions); Response.Cookies.Append("nomeUsuario", u.Nome, ckOptions); return(Json("")); } else { return(Json("O usuário e/ou senha não confere(m).")); } } else { return(Json("Por favor, informe o usuário e a senha para acesso")); } }