public List <ETipoUsuario> Listar() { MySqlConnection cnn = new MySqlConnection(ConfigurationManager.AppSettings["ConexaoBanco"]); MySqlCommand cmd = new MySqlCommand(); cnn.ConnectionString = Conexao.Caminho; cmd.Connection = cnn; //cnnTipoUsuario = ConexaoSingleton.getInstancia(); //cmd.Connection = cnnTipoUsuario.conexaoMysql(); cmd.CommandText = "SELECT * FROM TipoUsuario "; cnn.Open(); MySqlDataReader retorno = cmd.ExecuteReader(); List <ETipoUsuario> lstRetorno = new List <ETipoUsuario>(); //Se, e enquanto, existerem registros, percorre o datareader while (retorno.Read()) { ETipoUsuario obj = new ETipoUsuario(); PreencherObjeto(retorno, obj); lstRetorno.Add(obj); } cnn.Close(); return(lstRetorno); }
public ETipoUsuario Consultar(int identificador) { MySqlConnection cnn = new MySqlConnection(ConfigurationManager.AppSettings["ConexaoBanco"]); MySqlCommand cmd = new MySqlCommand(); cnn.ConnectionString = Conexao.Caminho; cmd.Connection = cnn; //cnnTipoUsuario = ConexaoSingleton.getInstancia(); //cmd.Connection = cnnTipoUsuario.conexaoMysql(); cmd.CommandText = @"SELECT * FROM TipoUsuario WHERE Identificador = @id"; cmd.Parameters.Add("@id", identificador); cnn.Open(); MySqlDataReader rdr = cmd.ExecuteReader(); ETipoUsuario retorno = new ETipoUsuario(); if (rdr.Read()) { PreencherObjeto(rdr, retorno); } cnn.Close(); return(retorno); }
public Estudante( string id, string nome, string sobrenome, DateTime dataNascimento, string sexo, string email, string curso, string areaCurso, int semestre, string descricao, int valorMensal, ETipoUsuario tipoUsuario ) { this.Id = id; this.Nome = nome; this.Sobrenome = sobrenome; this.DataNascimento = dataNascimento; this.Sexo = sexo; this.Email = email; this.Curso = curso; this.AreaCurso = areaCurso; this.Semestre = semestre; this.Descricao = descricao; this.ValorMensal = valorMensal; this.TipoUsuario = tipoUsuario; }
public RegisterClienteCommand(string nome, string sobrenome, string email, string senha, ETipoUsuario papel) { Nome = nome; Sobrenome = sobrenome; Email = email; Senha = senha; Papel = papel; }
public Usuario(Email email, string senha, ETipoUsuario papel) { Email = email; Senha = senha; Papel = papel; AddNotifications( new Contract() .Requires() .HasMinLen(Senha, 6, nameof(Senha), "A senha ve ter no minimo 6 caracteres") .Join(email) ); }
public Usuario( string id, string nome, string sobreNome, string senha, DateTime dtNascimento, string email, ETipoUsuario tipoUsuario ) { this.Id = id; this.Nome = nome; this.SobreNome = sobreNome; this.Senha = senha; this.DtNascimento = dtNascimento; this.Email = email; this.TipoUsuario = tipoUsuario; }
private static void PreencherObjeto(MySqlDataReader rdr, ETipoUsuario retorno) { retorno.Identificador = Convert.ToInt32(rdr["identificador"]); retorno.Descricao = rdr["Descricao"].ToString(); }
public Retorno Login(ViewLogin login) { var usuario = null as Usuario; try { var usuarios = _usuarioDao.Listar(0, login.Email, login.FirebaseId); if (!usuarios.Any()) { usuario = new Usuario() { Email = login.Email, FirebaseId = login.FirebaseId, Nome = login.Nome, Token = lib.Util.GerarTokenNumerico(), Tipo = login.TipoUsuario, DataHoraUltimoLogin = DateTime.Now, DataHoraUltimoAcesso = DateTime.Now, DataHoraCadastro = DateTime.Now, Ativo = true, FotoUrl = login.FotoUrl, Telefone = login.Telefone }; if (string.IsNullOrEmpty(usuario.Nome)) { usuario.Nome = usuario.Email.Split('@')[0]; usuario.Nome = usuario.Nome.Replace('.', ' ').Replace('-', ' '); } _contexto.Add <Usuario>(usuario); ETipoUsuario tipo = (ETipoUsuario)usuario.Tipo; switch (tipo) { case ETipoUsuario.Frigorifico: var f = new Frigorifico() { UsuarioId = usuario.Id }; _contexto.Add <Frigorifico>(f); break; case ETipoUsuario.Produtor: var p = new Produtor() { UsuarioId = usuario.Id, Comprador = false }; _contexto.Add <Produtor>(p); break; case ETipoUsuario.Tecnico: var t = new Tecnico() { UsuarioId = usuario.Id }; _contexto.Add <Tecnico>(t); break; } _contexto.SaveChanges(); } else { usuario = usuarios.First(); usuario.Token = lib.Util.GerarTokenNumerico(); usuario.DataHoraUltimoLogin = DateTime.Now; this.Save(); } return(Sucesso((ViewPerfil)usuario)); } catch (Exception ex) { return(Erro(ex)); } }