Esempio n. 1
0
        public async Task RegistrarEntrada(ControleDeVeiculo controleDeVeiculos)
        {
            var parametros = new
            {
                Veiculo         = controleDeVeiculos.Veiculo.ID,
                Estabelecimento = controleDeVeiculos.Estabelecimento.ID,
                controleDeVeiculos.DataEntrada
            };

            using (var scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
            {
                try
                {
                    using (var connection = _connectionFactory.CreateConnection())
                    {
                        await connection.ExecuteAsync(ControleDeVeiculoQueries.RegistrarEntrada, parametros);

                        scope.Complete();
                    }
                }
                catch (Exception e)
                {
                    scope.Dispose();
                    throw new Exception("Erro ao registrar evento", e);
                }
            }
        }
Esempio n. 2
0
        public static async Task Saida(TokenResponse tokenResponse)
        {
            var apiClient = new HttpClient();

            apiClient.SetBearerToken(tokenResponse.AccessToken);

            var body = new ControleDeVeiculo()
            {
                ID      = 1,
                Veiculo = new Veiculo()
                {
                    ID = 1
                },
                Estabelecimento = new Estabelecimento()
                {
                    ID = 1
                },
                DataSaida = DateTime.Now
            };
            var json = JsonConvert.SerializeObject(body);
            var data = new StringContent(json, Encoding.UTF8, "application/json");

            var response = await apiClient.PutAsync($"{API_URL_PREFIX}/ControleDeVeiculos/saida", data);

            Console.WriteLine(response.StatusCode);
        }
 public async Task RegistrarEntrada(ControleDeVeiculo controleDeVeiculos)
 {
     controleDeVeiculos.DataEntrada = DateTime.Now;
     await _controleDeVeiculosRepository.RegistrarEntrada(controleDeVeiculos);
 }