コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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());
        }