public async Task <string> GetBackgroundImageAsync(string city, string weather) { var searchWeather = weather.Replace(" ", "+"); var cityBackground = await RepositoryManager.CityBackgroundRepository.GetItemAsync(city, searchWeather).ConfigureAwait(false); if (cityBackground == null) { var remoteImage = await GetAsync <CityBackground>($"api/images/{city}", requestMessage => { requestMessage.Headers.Add("key", "B50996A0-9D60-44AF-BF08-81029CE2B8C7"); }).ConfigureAwait(false); cityBackground = new CityBackground { Name = city, WeatherOverview = searchWeather, ImageUrl = remoteImage.ImageUrl }; await RepositoryManager.CityBackgroundRepository.InsertAsync(cityBackground).ConfigureAwait(false); } return(await WebImageCache.RetrieveImage(cityBackground.ImageUrl, $"{city}-{searchWeather}")); }
public async Task <string> GetBackgroundImageAsync(string city, string weather) { var searchWeather = weather.Replace(" ", "+"); var remoteImage = await GetAsync <CityBackground>($"BackgroundByCityAndWeather?city={city}&weather={searchWeather}&height=1920").ConfigureAwait(false); var cityBackground = new CityBackground { Name = city, WeatherOverview = searchWeather, ImageUrl = remoteImage.ImageUrl }; return(await WebImageCache.RetrieveImage(cityBackground.ImageUrl, $"{city}-{searchWeather}")); }