public override IEnumerable <Forecast> GetForecast(City city) { var forecast = _repository.FindForecast(city.CityID); if (forecast.Count() == 0) { forecast = _yrWebservice.GetForecast(city); _repository.AddForecast(forecast); _repository.Save(); } else { foreach (Forecast item in forecast) { if (item.NextUpdate < DateTime.Now) { _repository.DeleteForecast(forecast); _repository.Save(); forecast = _yrWebservice.GetForecast(city); _repository.AddForecast(forecast); _repository.Save(); break; } } } return(forecast); }
public async Task <IActionResult> DeleteForecast(int id) { var forecastFormDB = await _repo.DeleteForecast(id); return(Ok()); }