Beispiel #1
0
        public Task <int> InserirAsync(Carro carro)
        {
            const string sql = @"insert into carros (id_carro, id_modelo, placa, ano) values (@Id, @IdModelo, @Placa, @Ano); select last_insert_id();";

            var dto = new CarroDto(carro);

            return(_dbConnection.ExecuteScalarAsync <int>(sql, dto));
        }
Beispiel #2
0
        public async Task <bool> AtualizarAsync(Carro carro)
        {
            const string sql = @"update carros set placa = @Placa, id_modelo = @IdModelo, ano = @Ano where id_carro = @Id";

            var dto = new CarroDto(carro);
            var registrosAfetados = await _dbConnection.ExecuteAsync(sql, dto);

            return(registrosAfetados == 1);
        }
Beispiel #3
0
        public ServiceResponse <bool> Put([FromBody] CarroDto carro)
        {
            var retorno = new ServiceResponse <bool> {
                Result = false
            };

            try
            {
                _appService.Update(carro);
                retorno.Result = true;
            }
            catch (Exception ex)
            {
                retorno.Message = ex.Message;
            }

            return(retorno);
        }