예제 #1
0
        public void TransferenciaInterna(TransferenciaApi transferenciaApi, OrigemOperacao origem)
        {
            var transferencia = transferenciaApi.ToModel(origem);

            Debito(transferencia);
            Credito(transferencia);
        }
예제 #2
0
 public static Transferencia ToModel(this TransferenciaApi model, OrigemOperacao origem)
 {
     return(new Transferencia
     {
         ContaCredito = model.Credit.Idenfifier,
         ContaDebito = model.Debit.Idenfifier,
         Operacao = RetornaTipoOperacao(origem),
         DataOperacao = model.Date,
         Valor = model.Value
     });
 }
예제 #3
0
 public static DebitoApi ToDebitoApi(this TransferenciaApi model)
 {
     return(new DebitoApi
     {
         Date = model.Date,
         Value = model.Value,
         Debit = new Debit
         {
             Idenfifier = model.Debit.Idenfifier,
             Name = model.Debit.Name
         }
     });
 }
예제 #4
0
 public IActionResult Transferir([FromBody] TransferenciaApi transferencia)
 {
     if (ModelState.IsValid)
     {
         try
         {
             _transferenciaService.TransferenciaInterna(transferencia, OrigemOperacao.Transferencia);
             return(Ok());
         }
         catch (Exception ex)
         {
             return(BadRequest(ex.Message));
         }
     }
     return(BadRequest());
 }