public RetornoUsuario Logar(string email, string senha) { var retorno = new RetornoUsuario(); retorno.Erro = false; retorno.Mensagem = new System.Collections.Generic.List <string>(); try { if (string.IsNullOrEmpty(email)) { retorno.Erro = true; retorno.Mensagem.Add("E-mail não informado"); return(retorno); } if (string.IsNullOrEmpty(senha)) { retorno.Erro = true; retorno.Mensagem.Add("Senha não informada"); return(retorno); } var contexto = new DB.Contexto(); var usuario = contexto.UsuarioDB.Where(u => u.Email.Trim().ToUpper() == email.Trim().ToUpper()).FirstOrDefault(); if (usuario == null) { retorno.Erro = true; retorno.Mensagem.Add("Usuário não localizado"); return(retorno); } if (usuario.Senha != Criptografia.Encrypt(senha)) { retorno.Erro = true; retorno.Mensagem.Add("Senha inválida"); return(retorno); } usuario.Senha = ""; retorno.Usuario = usuario; return(retorno); } catch (Exception ex) { retorno.Erro = true; retorno.Mensagem.Add(ex.Message); return(retorno); } }
public static UsuarioBE CarregarUsuarioPorId(int idUsuario) { try { var contexto = new DB.Contexto(); return(contexto.UsuarioDB.Find(idUsuario)); } catch (Exception) { return(null); } }
public static RespostaBE LembrarSenha(string email, string emailSMTP, string senhaSMTP) { var resposta = RespostaBE.NovaResposta(); var contexto = new DB.Contexto(); var usuario = contexto.UsuarioDB.Where(u => u.Email.Trim().ToLower() == email.Trim().ToLower()).FirstOrDefault(); if (usuario == null) { resposta.Erro = true; resposta.Mensagem.Add("E-mail não localizado"); return(resposta); } var mail = new Mail(emailSMTP, senhaSMTP); resposta = mail.LembrarEmail(usuario); return(resposta); }
public UsuarioBO() { contexto = new DB.Contexto(); }