Пример #1
0
        public async Task ShouldReturnFail_AfterHandle_InvalidRequestParameters(string expected, string customerId, string securityId, decimal securityNetValue, decimal securityQuantity, decimal withdrawalValue)
        {
            var checkBoxes = new List <TypeQuestions>();

            new TypeQuestions(customerId);
            new TypeQuestions(securityId);
            new TypeQuestions(securityQuantity.ToString());
            new TypeQuestions(securityNetValue.ToString());
            new TypeQuestions(withdrawalValue.ToString());

            var request = new CollateralExceededByValueQuery(checkBoxes);
            Response <QuestionsResponse> response = await _handler.Handle(request, CancellationToken.None);

            response.IsFailure.Should().BeTrue();
            response.Messages.Contains(expected).Should().BeTrue();
        }
Пример #2
0
        public async Task <Response <QuestionsResponse> > Handle(CollateralExceededByValueQuery request, CancellationToken cancellationToken)
        {
            var requestId = Guid.NewGuid().ToString();

            if (request == null)
            {
                return(Response <QuestionsResponse> .Fail(Messages.InvalidRequest));
            }
            if (request.CheckBoxes == null || !request.CheckBoxes.Any())
            {
                return(Response <QuestionsResponse> .Fail(Messages.InvalidCustomerId));
            }

            var response = new QuestionsResponse();


            // var customerHash = customerId.GenerateSha256Hash();

            try
            {
                var getQuestions = await _ripeRepository.GetQuestions();

                if (getQuestions == null)
                {
                    return(Response <QuestionsResponse> .Fail(new Error("GenericError",
                                                                        $"RequestId: {requestId} - Erro ao obter questionário no banco",
                                                                        StatusCodes.Status204NoContent)));
                }

                response.survey = getQuestions;

                return(Response <QuestionsResponse> .Ok(response));
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, $"RequestId: {requestId} - Erro ao obter questionário no banco");
                return(Response <QuestionsResponse> .Fail(new Error("GenericError",
                                                                    $"RequestId: {requestId} - Erro ao obter questionário no banco",
                                                                    StatusCodes.Status500InternalServerError)));
            }
        }