public async Task <IActionResult> Get( [FromQuery, BindRequired] Dictionary <string, string> currencyCodes, [FromQuery, BindRequired] DateTime startDate, [FromQuery, BindRequired] DateTime endDate, [FromQuery, BindRequired] string apiKey) { _logger.LogInformation("/get requested"); if (await _apiKeyService.IsValid(apiKey) == false) { return(StatusCode(403, "Invalid api key")); } else if (startDate > DateTime.Now) { return(NotFound("Start date is form future")); } else if (startDate > endDate) { return(BadRequest("Start date is greater than End date")); } foreach (var codesPair in currencyCodes) { if (Regex.IsMatch(codesPair.Key, CURRENCY_CODE_REGEX) == false || Regex.IsMatch(codesPair.Value, CURRENCY_CODE_REGEX) == false) { return(BadRequest($"Pair from currencyCodes({codesPair.Key},{codesPair.Value}) is invalid")); } } var currencyExchanges = await _currenciesService.GetExchanges(currencyCodes.ToList(), startDate, endDate); return(Ok(currencyExchanges)); }