private async Task <CityForecastItem> SearchCityById(int cityId) { if (_weatherForecastService is null) { _weatherForecastService = new WeatherForecastService(); } // update the model await _weatherForecastService.LoadWeatherData(cityId); // create an item for storing data about weather for searched city CityForecastItem item = new CityForecastItem { CityId = _weatherForecastService.CityId, CityName = _weatherForecastService.CityName, Description = _weatherForecastService.Description, MainTemp = _weatherForecastService.MainTemp.ToString() + Constants.CelsiusDegree, FeelTemp = _weatherForecastService.FeelTemp.ToString() + Constants.CelsiusDegree, MinTemp = _weatherForecastService.MinTemp.ToString() + Constants.CelsiusDegree, MaxTemp = _weatherForecastService.MaxTemp.ToString() + Constants.CelsiusDegree, Pressure = _weatherForecastService.Pressure.ToString() + Constants.PressureUnit, Humidity = _weatherForecastService.Humidity.ToString() + Constants.PercentSymbol, Wind = _weatherForecastService.Wind.ToString() + Constants.SpeedUnit, WeatherIconPath = Constants.WeatherIconPathPart1 + _weatherForecastService.WeatherIconName + Constants.WeatherIconPathPart2, }; return(item); }
public async Task SearchCity() { if (_weatherForecastService is null) { _weatherForecastService = new WeatherForecastService(); } // update the model await _weatherForecastService.LoadWeatherData(SearchString); // update favorite icon await IsCityInFavorites(); // update the view with data from the model PushDataToTheView(); }
private async Task LoadWeatherForCurrentLocation() { if (_weatherForecastService == null) { _weatherForecastService = new WeatherForecastService(); } Geolocalizator _geolocalizator = new Geolocalizator(); // get current city name string city = await _geolocalizator.GetLocationAsync(); // update the model await _weatherForecastService.LoadWeatherData(city); PushDataToTheView(); }