public IActionResult Index() { var model = new WeatherViewModel(); model.WeatherList = _weatherData.GetWeather(); model.CurrentDate = DateTime.Now.ToShortDateString(); return(View(model)); }
public CustomFile GetTxtFile() { var weatherList = _weatherData.GetWeather(); var filePath = $"{Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)}\\Downloads\\Pogoda.txt"; using (var sw = new StreamWriter(filePath)) { foreach (var w in weatherList) { sw.WriteLine(($"{w.Date}, {w.DayOfWeek}, {w.Temp}, {w.Wind}, {w.Clouds}, {w.Rain}, {w.Pressure}, {w.UV}")); } } var newFile = new CustomFile { FileContents = File.ReadAllBytes(filePath), ContentType = "text/plain", FileName = "Pogoda.txt" }; return(newFile); }
/// <summary> /// GetTempretures /// </summary> /// <param name="cityName"></param> /// <returns></returns> public async Task <List <Weather> > GetTempretures(List <string> cityName) { List <Weather> test = new List <Weather>(); foreach (var city in cityName) { var temp = await _weatherData.GetWeather(city).ConfigureAwait(false); if (temp != null) { test.Add(temp); } } return(test.OrderByDescending(t => t.Teamperature).ToList()); }