public Transacao(TransacaoRequest transacaoRequest) { DataTransacao = DateTime.Now; ValorTransacao = transacaoRequest.ValorTransacao; ValorRepasse = CalcularValorRepasse(transacaoRequest.ValorTransacao, transacaoRequest.NumeroParcelas); NumeroParcelas = transacaoRequest.NumeroParcelas; DigitosCartao = transacaoRequest.NumeroCartao.Substring(12, 4); ClientId = transacaoRequest.ClienteId; }
public async Task retornar_status_code_500_quando_saldo_insuficiente_ao_efetuar_retirada() { var request = new TransacaoRequest { IdConta = 2, Valor = 1000 }; var httpResponseMessage = await _client.PostAsync("/conta/retirada", SerializeRequest(request)); httpResponseMessage.StatusCode.Should().Be(HttpStatusCode.InternalServerError); }
public async Task Deve_efetuar_pagamento_na_conta_corrente() { var request = new TransacaoRequest { IdConta = 3, Valor = 100 }; var httpResponseMessage = await _client.PostAsync("/conta/pagamento", SerializeRequest(request)); httpResponseMessage.StatusCode.Should().Be(HttpStatusCode.Accepted); }
public async Task retornar_status_code_500_quando_conta_corrente_nao_existente_ao_efetuar_deposito() { var request = new TransacaoRequest { IdConta = 5, Valor = 100 }; var httpResponseMessage = await _client.PostAsync("/conta/deposito", SerializeRequest(request)); httpResponseMessage.StatusCode.Should().Be(HttpStatusCode.InternalServerError); }
public StatusCodeResult EfetuarTransacao(TransacaoRequest transacaoRequest) { try { transacao.EfetuarTransacao(transacaoRequest); return(StatusCode(StatusCodes.Status200OK)); } catch (Exception) { return(StatusCode(StatusCodes.Status500InternalServerError)); } }
public IActionResult PostEfetuarRetiradaConta ( [FromBody] TransacaoRequest request ) { _efetuarDebitoUseCase.Execute(new TransacaoDto { Tipo = TipoTransacao.Retirada, Valor = request.Valor, IdConta = request.IdConta, Descricao = request.Descricao }); return(Accepted()); }
public IActionResult PostTransacao([FromBody] TransacaoRequest transacaoRequest) { try { var transacao = new Transacao(transacaoRequest); _context.Transacoes.Add(transacao); _context.SaveChanges(); return(Created("Transacao", transacao)); } catch (Exception) { return(BadRequest()); } }
public void EfetuarTransacao(TransacaoRequest transacaoRequest) { Conta contaCredito = contaRepository.Get(transacaoRequest.ContaCreditoId); Conta contaDebito = contaRepository.Get(transacaoRequest.ContaDebitoId); using (var transacao = unitOfWork.BeginTransaction()) { contaCredito.Saldo += transacaoRequest.Valor; operacaoCredito.Adicionar(contaCredito, transacaoRequest.Valor); contaRepository.Update(contaCredito); contaDebito.Saldo -= transacaoRequest.Valor; operacaoDebito.Adicionar(contaDebito, transacaoRequest.Valor); contaRepository.Update(contaDebito); unitOfWork.Commit(); transacao.Commit(); } }
private StringContent SerializeRequest(TransacaoRequest request) { var content = JsonConvert.SerializeObject(request); return(new StringContent(content, Encoding.UTF8, "application/json")); }