Example #1
0
        public WeatherDateTimeContent(int timeOut, string stationId, int index)
        {
            TimeOut        = timeOut;
            IndexInContent = index;
            Manager        = new PredictManager();
            var latitudeAndLongitude = (new PredictManager()).GetLatLngStationFor(stationId);

            //if (!string.IsNullOrEmpty(latitudeAndLongitude))
            //{
            //    var buff = latitudeAndLongitude.Split(';');
            //    Coord = new Coord()
            //    {
            //        lat = buff[0],
            //        lon = buff[1]
            //    };
            //}
            //else
            //{
            //    Coord = new Coord()
            //    {
            //        lat = "",
            //        lon = ""
            //    };
            //}
            ContentType = ContentType.WEATHER_DATE_TIME;
        }
Example #2
0
        public new object PresentContent()
        {
            var weather = AbstractPredictManager.GetWeatherCity();

            return(new WeatherViewModel(weather, Manager));
        }
Example #3
0
        public WeatherViewModel(WeatherCity weatherCity, AbstractPredictManager manager)
        {
            //var bufferDate = manager.UnixTimeStampToDateTime(weatherCity.dt);
            if (manager == null || (weatherCity?.weather == null || (!weatherCity.weather?.Any() ?? false)))
            {
                return;
            }
            CurrentDate = DateTime.Now
                          .ToString("dd.MM.yyyy", CultureInfo.InvariantCulture);       //bufferDate.ToShortDateString();
            CurrentTime = DateTime.Now
                          .ToString("HH:mm", CultureInfo.InvariantCulture);
            Temperature           = manager.KelvinToCelcia(kelvinTemperature: weatherCity.main?.temp ?? 0) + "`C";
            DirectionAndSpeedWind = manager.CreateDirectionAndSpeedWind(weatherCity.wind);
            SpeedWind             = ((int)(weatherCity.wind?.speed ?? 0)) + "м/с";
            PrecipationIcon       = DateTime.Now
                                    .TimeOfDay
                                    .ToString();
            var buffPrecipitation = weatherCity.weather
                                    .FirstOrDefault()
                                    ?.description ?? "";

            switch (buffPrecipitation)
            {
            case "overcast clouds":
                Precipation  = "Переменная облачность";
                Precipation2 = "Облачно";
                break;

            case "clear sky":
                Precipation = "Солнечно";
                break;

            case "few clouds":
                Precipation  = "Переменная облачность";
                Precipation2 = "Облачно";
                break;

            case "scattered clouds":
                Precipation  = "Небольшая облачность";
                Precipation2 = "Облачно";
                break;

            case "broken clouds":
                Precipation  = "Облачно";
                Precipation2 = "Облачно";
                break;

            case "shower rain":
                Precipation  = "Сильный дождь";
                Precipation2 = "Дождь";
                break;

            case "rain":
                Precipation  = "Дождь";
                Precipation2 = "Дождь";
                break;

            case "thunderstorm":
                Precipation  = "Гроза";
                Precipation2 = "Гроза";
                break;

            case "snow":
                Precipation  = "Снег";
                Precipation2 = "Снег";
                break;

            case "light snow":
                Precipation  = "Небольшой снег";
                Precipation2 = "Снег";
                break;

            case "mist":
                Precipation  = "Туман";
                Precipation2 = "Туман";
                break;

            default:
                Precipation  = "Переменная";
                Precipation2 = "Переменная";
                break;
            }
            PrecipationIcon = $"~/../../Content/Images/weatherIcons/" + (weatherCity.weather.Any() ? $"{weatherCity.weather.FirstOrDefault()?.icon ?? ""}.png" :"01d.png");
        }