public void TransferenciaInterna(TransferenciaApi transferenciaApi, OrigemOperacao origem) { var transferencia = transferenciaApi.ToModel(origem); Debito(transferencia); Credito(transferencia); }
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 }); }
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 } }); }
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()); }