public Task <WeatherForcastResponseDto> Get([FromQuery] WeatherForcastRequestDto requestDto) { requestDto.Validate(); Func <Task <WeatherForcastResponseDto> > weatherForecastCache = () => _weatherForcastService.Get(requestDto); return(_cache.GetOrAddAsync <WeatherForcastResponseDto>(requestDto.GetRequestValue().value, weatherForecastCache, DateTimeOffset.Now.AddHours(1))); }
public async Task <WeatherForcastResponseDto> Get(WeatherForcastRequestDto requestDto) { WeatherForecastResponse weatherForecastResponse = new WeatherForecastResponse(); _ = (requestDto.GetRequestValue() switch { (nameof(requestDto.City), _) => weatherForecastResponse = await _weatherForecast.GetWeatherForecastByCityNameAsync(requestDto.City, Countries.Germany), (nameof(requestDto.ZipCode), _) => weatherForecastResponse = await _weatherForecast.GetWeatherForecastByZipCodeAsync(requestDto.ZipCode, Countries.Germany), (_, _) => throw new RequestInvalidException("Input must be identified!") });