Ejemplo n.º 1
0
        public async Task <List <object> > BuscaPorMarcaAsync(int id_marca)
        {
            var retorno = await _dapper.QueryAsync <Veiculo>($@"SELECT *  from veiculo WHERE id_marca = '{id_marca}'");

            ConcurrentBag <Veiculo> veiculo = new ConcurrentBag <Veiculo>(retorno);

            foreach (var item in veiculo)
            {
                var        queryTwo   = $"SELECT * FROM  marca WHERE id = {item.id_marca}";
                var        queryThree = $"SELECT * FROM  modelo WHERE id = {item.id_modelo}";
                GridReader gridReader = await _dapper.QueryMultipleAsync(queryTwo + " " + queryThree);

                var marca  = gridReader.Read <Marca>().FirstOrDefault();
                var modelo = gridReader.Read <Modelo>().FirstOrDefault();
                item.marca  = marca;
                item.modelo = modelo;
            }



            return(veiculo.AsList <object>());
        }
Ejemplo n.º 2
0
        public async Task <object> BuscaAsync(string matricula, string senha)
        {
            Usuario operador = null;
            //return await _dapper.QueryAsync<T>(@"SELECT id, nome, cpf, matricula, aniversario,cep,logradouro,numero,complemento,cidade,estado from usuario");
            List <Usuario> retorno = await _dapper.QueryAsync <Usuario>($@"SELECT id, nome, matricula  from usuario WHERE id = '{matricula}' AND senha = '{senha}'");

            if (retorno.Any())
            {
                operador      = retorno.FirstOrDefault();
                operador.role = "OPERADOR";
            }
            return(operador);
        }
Ejemplo n.º 3
0
        public async Task <object> BuscaAsync(string cpf, string senha)
        {
            Usuario cliente = null;
            //return await _dapper.QueryAsync<T>(@"SELECT id, nome, cpf, matricula, aniversario,cep,logradouro,numero,complemento,cidade,estado from usuario");
            List <Usuario> retorno = await _dapper.QueryAsync <Usuario, Endereco, Usuario>($@"SELECT id, nome, cpf, matricula, aniversario,cep,logradouro,numero,complemento,cidade,estado from usuario WHERE cpf = '{cpf}' AND senha = '{senha}'", (p, c) => { p.endereco = c; return(p); }, splitOn : "cep");

            if (retorno.Any())
            {
                cliente      = retorno.FirstOrDefault();
                cliente.role = "CLIENTE";
            }
            return(cliente);
        }
Ejemplo n.º 4
0
        public async Task <List <T> > BuscaAsync <T>()
        {
            List <T> lista = await _database.QueryAsync <T>($"SELECT * FROM marca;");

            return(lista);
        }
Ejemplo n.º 5
0
        public async Task <List <T> > BuscaAsync <T>(int id_marca)
        {
            List <T> lista = await _database.QueryAsync <T>($"SELECT * FROM modelo WHERE id_marca = {id_marca};");

            return(lista);
        }