public async Task <RealizarTransferenciaResponse> ValidateAsync(RealizarTransferenciaRequest request) { var response = new RealizarTransferenciaResponse(); if (request == null) { return(GetRequestIsNullResponse <RealizarTransferenciaResponse>()); } return(response); }
public async Task <RealizarTransferenciaResponse> IncluirAsync(RealizarTransferenciaRequest request) { var response = new RealizarTransferenciaResponse(); try { response = await _validator.ValidateAsync(request); if (!response.Valido) { return(response); } } catch (Exception ex) { return(GetInvalidRequestResponse <RealizarTransferenciaResponse>(ex.InnerException.ToString())); } return(response); }
public async Task <IActionResult> PostAsync([FromBody] RealizarTransferenciaRequest request) { try { if (request == null) { throw new ArgumentException("Request inválido.", nameof(request)); } var result = await _movimento.RealizarTransferenciaAsync(request.ContaOrigemNumero, request.ContaDestinoNumero, request.Valor); if (result) { return(Ok()); } return(NoContent()); } catch (ArgumentException ae) { _logger.LogError(ae.Message, ae); return(BadRequest(ae.Message)); } catch (EntityNotFoundException nfx) { _logger.LogError(nfx.Message, nfx); return(NotFound(nfx.Message)); } catch (Exception ex) { _logger.LogError(ex.Message, ex); return(StatusCode(500, ex.Message)); } }
public async Task <ActionResult> RealizarOperacaoAsync([FromBody] RealizarTransferenciaRequest request) { var result = await _service.IncluirAsync(request); return(this.GetHttpResponse(result)); }