private async Task <Response> ObterTaxaPorId(AtualizarTaxaCommand request) { var response = Response.Ok(); try { TaxaCobranca = await _taxaCobrancaRepository.ObterPorId(request.Id); if (string.IsNullOrEmpty(TaxaCobranca.TaxaCobrancaId)) { response = Response.Fail(Errors.General.NotFound(nameof(TaxaCobranca), request.Id)); Logger.LogWarning($"{response.ErrorResponse}"); return(response); } } catch (Exception ex) { response = Response.Fail(Errors.General.InternalProcessError("ObterTaxaPorId", ex.Message)); Logger.LogError(ex, $"{response.ErrorResponse}"); return(response); } return(response); }
public async Task <RegistrarTaxaInCacheResponse> Handle(RegistrarTaxaInCacheCommand request, CancellationToken cancellationToken) { var response = (RegistrarTaxaInCacheResponse)request.Response; TaxaCobranca = await _taxaCobrancaRepository.ObterPorId(request.Id); var taxaResponse = TaxaCobranca.ConverterEntidadeParaResponse(); await _cacheRepository.Set(taxaResponse.Id, taxaResponse); await _cacheRepository.Set(taxaResponse.TipoSegmento, taxaResponse); return(response); }
private async Task <Response> ObterPorId(RegistrarTaxaInCacheCommand request) { try { TaxaCobranca = await _taxaCobrancaRepository.ObterPorId(request.Id); if (TaxaCobranca is null) { return(Response.Fail(Errors.General.NotFound(nameof(TaxaCobranca), request.Id))); } } catch (Exception ex) { return(Response.Fail(Errors.General.InternalProcessError("ObterTaxaPorId", ex.Message))); } return(Response.Ok()); }