public async Task SaveWeatherInfoAsync(BasicWeatherInfo info) { string json = _utils.SerializeToJson(info); await File.AppendAllTextAsync(_filePath, Environment.NewLine); await File.AppendAllTextAsync(_filePath, $"{DateTime.Now}-----{json}"); }
public void ShowWeatherInfo(BasicWeatherInfo info) { Console.WriteLine(new string('-', 50)); Console.WriteLine($"Service: {info.ServiceName}"); Console.WriteLine($"Temp: {info.Temperature}, Wind: {info.Wind}, Clouds: {info.Clouds}"); Console.WriteLine(new string('-', 50)); }
static async Task Main(string[] args) { IWeatherInfoManager manager = WeatherInfoServiceFactory.GetWeatherInfoManager(); BasicWeatherInfo info = await manager.GetWeatherInfoAsync("Kiev"); manager.ShowWeatherInfo(info); await manager.SaveWeatherInfoAsync(info); Console.ReadKey(); }
public virtual async Task <BasicWeatherInfo> GetWeatherInfoAsync(string city) { List <Task <BasicWeatherInfo> > tasks = new List <Task <BasicWeatherInfo> >(); IEnumerable <IWeatherInfoService> services = WeatherInfoServiceFactory.GetWeatherServices(); services.ForEach(service => tasks.Add(service.GetWeatherInfoAsync(city))); BasicWeatherInfo result = await tasks.GetFirstSuccessfulTask(); return(result); }
public virtual void ShowWeatherInfo(BasicWeatherInfo info) { _viewManager.ShowWeatherInfo(info); }
public virtual async Task SaveWeatherInfoAsync(BasicWeatherInfo info) { await _repository.SaveWeatherInfoAsync(info); }