Beispiel #1
0
        public IActionResult GetRates([FromQuery(Name = "from")] string fromCurrency, [FromQuery(Name = "to")] string toCurrency)
        {
            if (!IsValid(fromCurrency, toCurrency, out var validationErrors))
            {
                return(BadRequest(ResponseModel.FromErrors(validationErrors)));
            }

            var rateModel = new RateModel
            {
                Value = UsdConversionRates[fromCurrency] / UsdConversionRates[toCurrency]
            };

            return(Ok(ResponseModel.FromSuccess(rateModel)));
        }