Esempio n. 1
0
        public async Task <ObterTaxaCobrancaPorSegmentoResponse> Handle(ObterTaxaCobrancaPorSegmentoQuery request, CancellationToken cancellationToken)
        {
            var response = (ObterTaxaCobrancaPorSegmentoResponse)request.Response;

            var tipoSegmento = TipoSegmento.ObterPorId(request.TipoSegmento);

            if (tipoSegmento is null)
            {
                response.AddError(Errors.General.NotFound("TipoSegmento", request.TipoSegmento));
                return(response);
            }

            var tipoSegmentoResponse = await _cacheProvider.GetValueOrCreate(tipoSegmento.Id,
                                                                             async() => await ObterTaxaCobrancaPorSegmento(request, response, tipoSegmento));

            if (tipoSegmentoResponse.Equals(default(TaxaResponse)))
            {
                response.AddError(Errors.General.NotFound("Segmento", request.TipoSegmento));
                return(response);
            }

            response.SetPayLoad(tipoSegmentoResponse);

            return(response);
        }
Esempio n. 2
0
        private void ObterTipoSegmentoPorId(RegistrarNovaTaxaCommand request, RegistrarNovaTaxaResponse response)
        {
            TipoSegmento = TipoSegmento.ObterPorId(request.Segmento);
            if (TipoSegmento is null)
            {
                response.AddError(Errors.General.NotFound(nameof(TipoSegmento), request.Segmento));

                Logger.LogWarning($"{response.ErrorResponse}");
                return;
            }
        }
Esempio n. 3
0
        public void ObterPorId_SOLUCAO_1()
        {
            var tipoSegmento = TipoSegmento.ObterPorId("VAREJO");

            Debug.WriteLine(tipoSegmento);
        }