예제 #1
0
        public static Response ValidarQuery(ObterCotacaoPorMoedaQuery request)
        {
            var validador = new ObterCotacaoPorMoedaQueryValidator();
            var resultado = validador.Validate(request);

            if (resultado.IsValid)
            {
                return(Response.Ok());
            }

            var invalidQueryParameters = Errors.General.InvalidQueryParameters();

            foreach (var failure in resultado.Errors)
            {
                invalidQueryParameters.AddErroDetail(Errors.General.InvalidArgument(failure.ErrorCode, failure.ErrorMessage));
            }

            return(Response.Fail(invalidQueryParameters));
        }
예제 #2
0
        public async Task <Response> Handle(ObterCotacaoPorMoedaQuery request, CancellationToken cancellationToken)
        {
            Response response = ObterCotacaoPorMoedaQueryValidator.ValidarQuery(request);

            if (response.IsFailure)
            {
                return(response);
            }

            response = ObterTipoSegmentoPorId(request);
            if (response.IsFailure)
            {
                return(response);
            }

            response = await ObterTaxaCobrancaPorSegmento(request);

            if (response.IsFailure)
            {
                return(response);
            }

            response = await OberUltimaCotacaoPorMoeda(request);

            if (response.IsFailure)
            {
                return(response);
            }

            response = ExecutarCalculoCotacao(request);
            if (response.IsFailure)
            {
                return(response);
            }

            response = CreateResponse(request);
            if (response.IsFailure)
            {
                return(response);
            }

            return(response);
        }