Beispiel #1
0
        public IActionResult CalculateExchangeValue([FromBody] CalculateExchangeValueInput input)
        {
            var useCaseInput = new ExchangeUseCaseInput
            {
                CurrencyId = input.CurrencyId,
                SegmentId  = input.SegmentId,
                Quantity   = input.Quantity
            };

            var useCaseOutput = this.exchangeUseCase.PerformOperation(useCaseInput);

            return(Ok(useCaseOutput.ExchangeValue));
        }
Beispiel #2
0
        public ExchangeUseCaseOutput PerformOperation(ExchangeUseCaseInput inputObject)
        {
            logger.LogInformation($"Recuperando moeda: [{inputObject.CurrencyId}]");
            var currency = currencyRepository.Get(inputObject.CurrencyId);

            logger.LogInformation($"Recuperando segmento: [{inputObject.SegmentId}]");
            var segment = segmentRepository.Get(inputObject.SegmentId);

            logger.LogInformation($"Recuperando taxa de conversão para: [{currency.Code}]");
            var exchangeRate = exchangeService.GetExchangeRate(currency.Code);

            var exchangeValue = (inputObject.Quantity * exchangeRate) * (1 + segment.ExchangeTax);

            return(new ExchangeUseCaseOutput
            {
                ExchangeValue = exchangeValue
            });
        }