Esempio n. 1
0
        public async Task <CurrencyConversionModelResponse> GetAllAsync()
        {
            var conversionRequest = new CurrencyConversionModelRequest()
            {
                CurrencyFrom = "EUR",
                CurrencyTo   = "USD",
                Amount       = 100
            };

            var result = new CurrencyConversionModelResponse()
            {
                FromConversion = new FromConversion()
                {
                    CurrencyCode = conversionRequest.CurrencyFrom,
                    Amount       = conversionRequest.Amount
                },
                ToConversion = new ToConversion()
                {
                    CurrencyCode = conversionRequest.CurrencyTo
                }
            };

            var conversionResult = await _currencyService.ConvertCurrencyFromAmountTo(conversionRequest);

            return(conversionResult);
        }
Esempio n. 2
0
        public async Task <CurrencyConversionModelResponse> ConvertCurrencyFromAmountTo([FromBody] CurrencyConversionModelRequest conversionRequest)
        {
            var conversionResult = await _currencyService.ConvertCurrencyFromAmountTo(conversionRequest);

            return(conversionResult);
        }
Esempio n. 3
0
        public async Task <CurrencyConversionModelResponse> ConvertCurrencyFromAmountTo(CurrencyConversionModelRequest conversionRequest)
        {
            var request = new ConversionRequestModel()
            {
                FromCurrency = conversionRequest.CurrencyFrom,
                ToCurrency   = conversionRequest.CurrencyTo,
                Amount       = conversionRequest.Amount
            };

            var result = await _currencyConversionService.ConvertCurrencyFromAmountTo(request);

            var conversionResponse = new CurrencyConversionModelResponse();

            if (result != null)
            {
                conversionResponse = ConversionResultToCurrencyConversionResponseMapper.MapConversionResultToCurrencyConversion(result);
            }

            return(conversionResponse);
        }