Example #1
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="location"></param>
    /// <returns></returns>
    public async Task <IActionResult> Index(string?location = null)
    {
        string         theLocation = VerifyLocation(location);
        CurrentWeather conditions  = await _weatherService.GetCurrentWeatherAsync(theLocation);

        var myList = new List <CurrentWeather>();

        if (!conditions.Success)
        {
            conditions.ErrorMessage = $"{conditions.ErrorMessage} received for location:{theLocation}";
            myList.Add(conditions);
        }

        var field      = typeof(MemoryCache).GetProperty("EntriesCollection", BindingFlags.NonPublic | BindingFlags.Instance);
        var collection = field.GetValue(_cache) as ICollection;
        var items      = new List <string>();

        if (collection != null)
        {
            foreach (var item in collection)
            {
                var methodInfo = item.GetType().GetProperty("Key");
                if (methodInfo.GetValue(item).ToString().Contains("WeatherConditions::"))
                {
                    var val = methodInfo.GetValue(item);
                    items.Add(val.ToString().Replace("WeatherConditions::", String.Empty));
                }
            }
        }
        foreach (var item in items)
        {
            myList.Add(await _weatherService.GetCurrentWeatherAsync(item));
        }
        return(View(myList));
    }
Example #2
0
 /// <summary>
 /// Used to force the weather effect on the map.
 /// Item validation is done.
 /// Will override existing weather effect.
 /// </summary>
 /// <param name="nItemID">Weather effect item ID</param>
 /// <param name="sMsg">Message to display on screen</param>
 protected void ForceWeatherEffect(int nItemID, string sMsg)
 {
     if (MasterManager.ItemTemplate(nItemID) is CashItemTemplate template)
     {
         CurrentWeather.UpdateItemInfo(nItemID, sMsg, template.WeatherType);
     }
 }
Example #3
0
        public async Task Getting_weather_for_valid_city_should_return_proper_data()
        {
            // Arrange
            var response = new CurrentWeather
            {
                Name = "London",
                Main = new Main {
                    Temp = 30
                },
                Weather = new List <Api.Models.Weather>
                {
                    new Api.Models.Weather {
                        Main = "Dizzy", Icon = "01d"
                    }
                }
            };

            var service = new WeatherService(GetClientWithResponse(response));

            // Act
            var data = await service.GetCurrentWeather("London");

            // Assert
            data.CityName = "London";
            data.Description.Should().Be("Dizzy");
            data.Icon.Should().Be("01d");
            data.Temperature.Should().Be(30);
        }
Example #4
0
 public Weather(CurrentWeather weather)
 {
     CityName      = weather.Name;
     Condition     = weather.Conditions.First().Description;
     ConditionIcon = weather.Conditions.First().ConditionIcon;
     Temperature   = weather.Detail.Temperature;
 }
Example #5
0
        public async Task Getting_weather_for_city_with_many_weather_elements_should_return_icon_and_description_from_first()
        {
            // Arrange
            var response = new CurrentWeather
            {
                Weather = new List <Api.Models.Weather>
                {
                    new Api.Models.Weather {
                        Main = "Rainy", Icon = "02d"
                    },
                    new Api.Models.Weather {
                        Main = "Dizzy", Icon = "01d"
                    },
                }
            };

            var service = new WeatherService(GetClientWithResponse(response));

            // Act
            var data = await service.GetCurrentWeather("London");

            // Assert
            data.Description.Should().Be("Rainy");
            data.Icon.Should().Be("02d");
        }
        private CurrentWeather MapCurrentConditionsResponse(CurrentConditionsResponse openWeatherApiResponse)
        {
            var currentConditions = new CurrentWeather()
            {
                Success      = true,
                ErrorMessage = String.Empty,
                Location     = new CurrentWeather.LocationData()
                {
                    Name      = openWeatherApiResponse.Name,
                    Latitude  = openWeatherApiResponse.Coordintates.Latitude,
                    Longitude = openWeatherApiResponse.Coordintates.Longitude
                },
                ObservationTime    = DateTimeOffset.FromUnixTimeSeconds(openWeatherApiResponse.ObservationTime + openWeatherApiResponse.TimezoneOffset).DateTime,
                ObservationTimeUtc = DateTimeOffset.FromUnixTimeSeconds(openWeatherApiResponse.ObservationTime).DateTime,
                CurrentConditions  = new CurrentWeather.WeatherData()
                {
                    Conditions            = openWeatherApiResponse.ObservedConditions.FirstOrDefault()?.Conditions,
                    ConditionsDescription = openWeatherApiResponse.ObservedConditions.FirstOrDefault()?.ConditionsDetail,
                    Visibility            = openWeatherApiResponse.Visibility / 1609.0, // Visibility always comes back in meters, even when imperial requested
                    CloudCover            = openWeatherApiResponse.Clouds.CloudCover,
                    Temperature           = openWeatherApiResponse.ObservationData.Temperature,
                    Humidity             = openWeatherApiResponse.ObservationData.Humidity,
                    Pressure             = openWeatherApiResponse.ObservationData.Pressure * 0.0295301, // Pressure always comes back in millibars, even when imperial requested
                    WindSpeed            = openWeatherApiResponse.WindData.Speed,
                    WindDirection        = CompassDirection.GetDirection(openWeatherApiResponse.WindData.Degrees),
                    WindDirectionDegrees = openWeatherApiResponse.WindData.Degrees,
                    RainfallOneHour      = (openWeatherApiResponse.Rain?.RainfallOneHour ?? 0.0) * 0.03937008
                },
                FetchTime = DateTime.Now
            };

            return(currentConditions);
        }
        public CurrentWeather GetCurrentWeather(string location)
        {

            CurrentWeather weather = _innerWeatherService.GetCurrentWeather(location);
            _logger.LogToFile("Temperature in " + location + " at " + DateTime.Now + " is " + weather.Temperature);
            return weather;
        }
Example #8
0
        private CurrentWeather GetCurrentWeather(string city)
        {
            //https://api.openweathermap.org/data/2.5/weather?q=Rivne&units=metric&APPID=f2b3af247004bf8543677aa8cb2a20de"));
            CurrentWeather weatherResult = null;

            try
            {
                HttpWebRequest webReq = (HttpWebRequest)WebRequest.
                                        Create(string.Format(WeatherApiCurrent + city + WeatherApiSettings));

                webReq.Method = "GET";

                HttpWebResponse webResp = (HttpWebResponse)webReq.GetResponse();

                string jsonString;
                using (Stream stream = webResp.GetResponseStream())
                {
                    StreamReader reader = new StreamReader(stream, System.Text.Encoding.UTF8);
                    jsonString = reader.ReadToEnd();
                }

                weatherResult = CurrentWeather.FromJson(jsonString);
            }
            catch (Exception e)
            {
                weatherResult = new CurrentWeather()
                {
                    RequestType = BadRequest
                };
            }

            return(weatherResult);
        }
        private void ReceiveWeather(string json)
        {
            currentWeather = JsonConvert.DeserializeObject <CurrentWeather>(json);
            WeatherDTO weatherDTO = mapper.MapCurrentWeather(currentWeather);

            OnWeatherReady(weatherDTO);
        }
        public object GetCurrent(string name)
        {
            string url = "http://api.openweathermap.org/data/2.5/weather?q=" + name + "&units=metric&appid=c37bd644e32f7c0ebeaaa246de06be0b";

            try
            {
                HttpWebRequest  httpWebRequest  = (HttpWebRequest)WebRequest.Create(url);
                HttpWebResponse httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse();

                string response;

                using (StreamReader streamReader = new StreamReader(httpWebResponse.GetResponseStream()))
                {
                    response = streamReader.ReadToEnd();
                }

                CurrentWeather weatherResponse = JsonConvert.DeserializeObject <CurrentWeather>(response);
                weatherResponse.Date = DateTime.Now.Date;
                return(weatherResponse);
            }
            catch (Exception e)
            {
                Error errorResponse = new Error
                {
                    Messege = e.Message
                };
                return(errorResponse);
            }
        }
        public CurrentWeather GetTemp(string zipcode)
        {
            CurrentWeather currentWeather = null;

            switch (zipcode)
            {
            case "77001":
                currentWeather = new CurrentWeather {
                    Temp = "71 F", City = "Dallas"
                };
                break;

            case "77002":
                currentWeather = new CurrentWeather {
                    Temp = "72 F", City = "Cypress"
                };
                break;

            default:
                currentWeather = new CurrentWeather {
                    Temp = "90 F", City = "Houston"
                };
                break;
            }
            return(currentWeather);
        }
        /// <summary>
        /// Fill current weather view with the weather data
        /// </summary>
        /// /// <param name="place">Place for which is forecast</param>
        async Task FillCurrentWeather(string place)
        {
            XmlSerializer serializer = new XmlSerializer(typeof(Current));
            string        xml;

            try
            {
                xml = await GetWeather(CurrentWeatherUrl, place, 7);
            }
            catch (HttpRequestException)
            {
                throw;
            }
            if (xml != null)
            {
                try
                {
                    TextReader reader   = new StringReader(xml);
                    Current    forecast = (Current)serializer.Deserialize(reader);
                    PlaceName.Content = forecast.City.Name + "," + forecast.City.Country;
                    CurrentWeather.Update(forecast);
                    reader.Dispose();
                }
                catch (InvalidOperationException)
                {
                    throw;
                }
            }
        }
Example #13
0
        public void TempretureIsWorking()
        {
            CurrentWeather WC     = new CurrentWeather();
            var            result = WC.TempCheck();

            Assert.AreEqual(true, result);
        }
Example #14
0
        public void HumidityIsWorking()
        {
            CurrentWeather WC     = new CurrentWeather();
            var            result = WC.HumidityCheck();

            Assert.AreEqual(true, result);
        }
Example #15
0
        public void WindSpeedIsWorking()
        {
            CurrentWeather WC     = new CurrentWeather();
            var            result = WC.WindCheck();

            Assert.AreEqual(true, result);
        }
Example #16
0
        public void Receive(WeatherChange weatherChange)
        {
            Weather previousWeather = CurrentWeather;

            if (SurroundingWeather == weatherChange.Weather)
            {
                if (CurrentWeather != SurroundingWeather)
                {
                    ChangeWeatherEventArgs changeWeatherEventArgs = new ChangeWeatherEventArgs(this, weatherChange);
                    OnChangeWeather?.Invoke(this, changeWeatherEventArgs);

                    CurrentWeather = SurroundingWeather;

                    WeatherChangedEventArgs weatherChangedEventArgs = new WeatherChangedEventArgs(this, previousWeather, CurrentWeather);
                    OnWeatherChanged?.Invoke(this, weatherChangedEventArgs);
                }
            }

            bool change = CurrentWeather == weatherChange.Weather;


            if (change)
            {
                ChangeWeatherEventArgs changeWeatherEventArgs = new ChangeWeatherEventArgs(this, weatherChange);
                OnChangeWeather?.Invoke(this, changeWeatherEventArgs);
            }

            CurrentWeather.Reset(weatherChange.TurnCount);

            if (change)
            {
                WeatherChangedEventArgs weatherChangedEventArgs = new WeatherChangedEventArgs(this, previousWeather, CurrentWeather);
                OnWeatherChanged?.Invoke(this, weatherChangedEventArgs);
            }
        }
    public async Task <IActionResult> getCurrentWeatherByZipCode(string zipcode = "90815")
    {
        CurrentWeather currentweather = null;

        using (var httpClient = new HttpClient()) {
            try{
                string url = "https://api.openweathermap.org/data/2.5/weather?zip=" + zipcode + "&APPID=" + API_KEY;

                var response = await httpClient.GetAsync(new Uri(url)).ConfigureAwait(false);

                response.EnsureSuccessStatusCode();

                var stringResult = await response.Content.ReadAsStringAsync();

                var rawData = JsonConvert.DeserializeObject <CurrentWeather>(stringResult);
                currentweather = new CurrentWeather {
                    weather = rawData.weather.Select(element => { element.icon = "http://openweathermap.org/img/w/" + element.icon + ".png"; return(element); }).ToList(),
                    main    = rawData.main
                };
                return(Ok(currentweather));
            }
            catch (HttpRequestException httpRequestException) {
                return(BadRequest($"Error getting data: {httpRequestException.Message}"));
            }
        }
    }
Example #18
0
        public void CloudsIsWorking()
        {
            CurrentWeather WC     = new CurrentWeather();
            var            result = WC.CloudCheck();

            Assert.AreEqual(true, result);
        }
Example #19
0
        public async Task ConfiguredWith_2SecondsTimeBetweenRetries_2_Retries_ExponentialBackoff()
        {
            var settings = new WeatherClientSettings("apiKey");

            settings.Retries                     = 2;
            settings.ThrowOnError                = false;
            settings.TimeBetweenRetries          = TimeSpan.FromSeconds(2);
            settings.ExponentialBackoffInRetries = true;
            int       timesTried = 0;
            Stopwatch stopwatch  = new Stopwatch();

            SetUpWithSettings(settings, () =>

            {
                timesTried++;
                var response = new HttpResponseMessage(System.Net.HttpStatusCode.InternalServerError);
                return(Task.FromResult(response));
            });

            stopwatch.Start();
            CurrentWeather weather = await client.GetByName("Barcelona");

            stopwatch.Stop();

            Assert.IsNull(weather);
            //one of the actual request and 2 for the retries
            Assert.AreEqual(3, timesTried);
            Assert.Greater(stopwatch.Elapsed, TimeSpan.FromSeconds(5));
        }
        public async Task InvokeAsync_Returns_ViewViewComponentResult()
        {
            // Arrange
            IConfigurationSection weatherConfig = _configuration.GetSection("Weather");

            var request = new ForecastRequest
            {
                City             = weatherConfig["City"],
                CountryCode      = weatherConfig["CountryCode"],
                LanguageCode     = Language.French.ToLanguageCode(),
                TemperatureScale = TemperatureScale.Fahrenheit.ToUnitsType(),
            };

            var serviceMock = new Mock <WeatherService>();

            serviceMock.Setup(stub => stub.GetCurrentWeatherAsync(request)).ReturnsAsync(GetTestForecast());

            var viewComponent = new CurrentWeather(serviceMock.Object);

            // Act
            var result = await viewComponent.InvokeAsync(
                weatherConfig["City"], weatherConfig["CountryCode"], TemperatureScale.Fahrenheit, Language.French);

            // Assert
            Assert.IsType <ViewViewComponentResult>(result);
        }
        /// <summary>
        /// Gets the weather.
        /// </summary>
        /// <returns>The weather.</returns>
        public async Task <CurrentWeather> GetWeather()
        {
            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri($"http://api.openweathermap.org/data/2.5/weather");

                try
                {
                    var json = await client.GetAsync($"?id={CityId}&APPID={API_KEY}&lang=pt");

                    var content = await json.Content.ReadAsStringAsync();

                    if (string.IsNullOrWhiteSpace(content))
                    {
                        throw new ArgumentNullException(nameof(json), "Erro ao coletar informações do tempo.");
                    }

                    weather = CurrentWeather.FromJson(content);
                    return(weather);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
        private void TelegramBot_ReceiveMessage(object sender, object[] obj)
        {
            long   chatId  = (long)obj[0];
            string message = obj[1].ToString();

            if (SelectedUser.TelegramId == chatId)
            {
                UpdateUserMessages();
            }

            Regex regex = new Regex(@"^/([tт])\s(\w+)$", RegexOptions.IgnoreCase);
            Match match = regex.Match(message);

            if (match.Success)
            {
                try
                {
                    GroupCollection groups = match.Groups;

                    CurrentWeather weather = currentWeather as CurrentWeather;
                    weather.GetWeather(groups[2].Value, units: "metric", lang: "ru");
                    string str = weather.GetCurrentTemp();
                    telegramBot.Send(chatId, str);
                }
                catch (Exception)
                {
                    telegramBot.Send(chatId, "Неправильное название города");
                }
                finally
                {
                    UpdateUserMessages();
                }
            }
        }
Example #23
0
 public CurrentWeatherDto(CurrentWeather currentWeather)
 {
     Coordinates = currentWeather.coord == null
         ? new CoordDto()
         : new CoordDto(currentWeather.coord);
     Base = currentWeather.@base;
     Main = currentWeather.main == null
         ? new MainDto()
         : new MainDto(currentWeather.main);
     Wind = currentWeather.wind == null
         ? new WindDto()
         : new WindDto(currentWeather.wind);
     Clouds = currentWeather.clouds == null
         ? new CloudsDto()
         : new CloudsDto(currentWeather.clouds);
     Dt  = currentWeather.dt;
     Sys = currentWeather.sys == null
         ? new SysDto()
         : new SysDto(currentWeather.sys);
     Id      = currentWeather.id;
     Name    = currentWeather.name;
     Code    = currentWeather.cod;
     Weather = new List <WeatherDto>();
     foreach (var weather in currentWeather.weather)
     {
         Weather.Add(new WeatherDto(weather));
     }
 }
Example #24
0
 private static void Write_Weather_To_Console(CurrentWeather weather)
 {
     foreach (var item in weather.Weather)
     {
         System.Console.WriteLine($"Weather Information: {item.Main}\n{item.Description}");
     }
 }
        public void SampleDataFromApiTest()
        {
            var currentWeather = new CurrentWeather("http://samples.openweathermap.org/data/2.5/weather?q=London,uk&appid=b1b15e88fa797225412429c1c50c122a1");
            var actual         = currentWeather.Data;

            var expected = new CurrentWeatherData();

            expected.Coord   = new Coordinates(-0.13, 51.51);
            expected.Weather = new List <Weather>
            {
                new Weather(300, "Drizzle", "light intensity drizzle", "09d")
            };
            expected.Base       = "stations";
            expected.Main       = new Main(280.32f, 1012, 81, 279.15f, 281.15f, 0, 0);
            expected.Visibility = 10000;
            expected.Wind       = new Wind(4.1f, 80);
            expected.Clouds     = new Clouds(90);
            expected.Dt         = 1485789600;
            expected.Sys        = new Sys(1, 5091, 0.0103f, "GB", 1485762037, 1485794875);
            expected.Id         = 2643743;
            expected.Name       = "London";
            expected.Cod        = 200;

            actual.ShouldDeepEqual(expected);
        }
        public StoredWeather Create(IWeather weather, string message, WeatherType type, int daysAhead)
        {
            var forecast = new StoredWeather();

            switch (type)
            {
            case WeatherType.Current:
                CurrentWeather currentWeather = weather as CurrentWeather;
                forecast.CityId       = currentWeather.Id;
                forecast.QueryDate    = DateTime.Now;
                forecast.RequiredDate = DateTime.Now;
                forecast.Type         = WeatherType.Current;
                forecast.Message      = message;
                break;

            case WeatherType.Forecast:
                WeatherForecast weatherForecast = weather as WeatherForecast;
                forecast.CityId       = weatherForecast.City.Id;
                forecast.QueryDate    = DateTime.Now;
                forecast.RequiredDate = DateTime.Now.AddDays(daysAhead);
                forecast.Type         = WeatherType.Forecast;
                forecast.Message      = message;
                break;
            }

            return(forecast);
        }
Example #27
0
        /// <summary>
        /// Configure List with API data
        /// </summary>
        /// <param name="weatherMap"></param>
        public void ConfigureListView(CurrentWeather weatherMap)
        {
            if (weatherMap != null)
            {
                label1.Text = weatherMap.primary[0].main;
                imgConfig.SetWeatherImage(this, label1.Text);

                // Create three items and three sets of subitems for each item.
                ListViewItem item1 = new ListViewItem(weatherMap.name, 0);
                item1.SubItems.Add(weatherMap.clouds.all.ToString() + " %");
                item1.SubItems.Add(weatherMap.main.temp.ToString() + " °C");
                item1.SubItems.Add(weatherMap.wind.speed.ToString() + " MPH");

                // Create columns for the items and subitems.
                // Width of -2 indicates auto-size.
                listView1.Columns.Add("Region", -2, HorizontalAlignment.Left);
                listView1.Columns.Add("Perspiration", -2, HorizontalAlignment.Left);
                listView1.Columns.Add("Temperature", -2, HorizontalAlignment.Left);
                listView1.Columns.Add("Wind", -2, HorizontalAlignment.Center);

                // Add the items to the ListView.
                listView1.Items.AddRange(new ListViewItem[] { item1 });
            }
            else
            {
                // if no data was found, or error occurred, populate list with dummy data
                DefaultListViewPopulation();
            }
        }
Example #28
0
        public ActionResult CurrentWeather(string city)
        {
            if (string.IsNullOrWhiteSpace(city))
            {
                return(View());
            }

            CurrentWeather weather = _weatherService.GetCurrentWeather(city);

            CurrentWeatherDTO weatherDTO = new CurrentWeatherDTO
            {
                City          = weather.City.Name,
                Country       = weather.City.Country,
                WeatherIcon   = weather.Weather.Icon,
                Temperature   = $"{weather.Temperature.Value.Split('.')[0]} °C",
                Cloudiness    = weather.Clouds.Name.ToUpper(),
                Wind          = $"{weather.Wind.Speed.Name}, {weather.Wind.Speed.Value} m/s",
                WindDirection = $"{weather.Wind.Direction.Name} ( {weather.Wind.Direction.Value} )",
                Pressure      = $"{weather.Pressure.Value} {weather.Pressure.Unit.ToLower()}",
                Humidity      = $"{weather.Humidity.Value} {weather.Humidity.Unit}",
                Sunrise       = weather.City.Sun.Rise.Split('T')[1],
                Sunset        = weather.City.Sun.Set.Split('T')[1],
                CoordLat      = weather.City.Coord.Lat,
                CoordLon      = weather.City.Coord.Lon
            };

            return(PartialView("_currentWeather", weatherDTO));
        }
        public void GetDataByCityZipCodeTest()
        {
            var currentWeather = new CurrentWeather(new CurrentWeather.Local("EC2M", "GB"), GetApiKey());
            var actual         = currentWeather.Data;

            Assert.IsTrue(currentWeather.IsValid());
            Assert.AreNotEqual(404, actual.Cod);
        }
        private async Task GetCurrentWeather()
        {
            _latitude  = _locationService.GetLatitude();
            _longitude = _locationService.GetLongitude();
            var apiService = RestService.For <IAPIService>("https://api.openweathermap.org");

            CurrentWeater = await apiService.GetCurrentWeatherByCoordinates(_latitude, _longitude, APIKey);
        }
        public void Initialize()
        {
            // arrange
            this.serviceMock = new WeatherServiceMock();
            this.target = new OldMainViewModel(serviceMock);

            this.dummyCurrentWeather = CreateDummyCurrentWeather();
            this.dummyWeatherInfo = CreateWeatherInfo();

            this.serviceMock
                .AddHandlers()
                    .GetCurrentWeatherAsync(() => Task.FromResult(dummyCurrentWeather))
                    .GetWeatherAsync(() => Task.FromResult(dummyWeatherInfo));
        }
Example #32
0
 public string GetPhrase(CurrentWeather model)
 {
     return this.GetString(GetPhraseResource(model));
 }
 private void Parse(CurrentWeather model)
 {
     this.City.Value = model.Name;
     this.Temperature.Value = this.resources.GetFormattedTemperature(model.MainInfo.Temperature);
     this.Wind.Value = this.resources.GetFormattedWind(model.Wind.Speed, model.Wind.Deg);
     this.Humidity.Value = this.resources.GetFormattedHumidity(model.MainInfo.Humidity);
     this.ImageResource.Value = this.resources.GetImageResource(model.Weather[0].Icon);
     this.Phrase.Value = this.resources.GetPhrase(model);
 }
 private void Parse(CurrentWeather model)
 {
     this.City.Value = model.Name;
     this.Temperature.Value = model.MainInfo.Temperature + " ºC";
     this.Wind.Value = model.Wind.Speed + "km/h " + model.Wind.Deg + "º";
     this.Humidity.Value = model.MainInfo.Humidity + "%";
     this.ImageResource.Value = "Img" + model.Weather[0].Icon.Replace(".png", "");
 
     if (model.MainInfo.Temperature < 5)
         this.Phrase.Value = "freezing\ncold\nlike a\n<red>f*****g</red>\nfridge.";
     else if (model.MainInfo.Temperature > 30)
         this.Phrase.Value = "it's too\n<red>damn</red> hot.";
     else if (model.MainInfo.Temperature >= 20 && model.MainInfo.Temperature <= 25 && model.Weather[0].Icon == "01d.png")
         this.Phrase.Value = "<red>f*****g</red>\nlove is\nin the air.";
     else if (model.MainInfo.Temperature >= 20 && model.MainInfo.Temperature <= 25)
         this.Phrase.Value = "it's\n<green>f*****g</green> whiskey\ntime.";
     else if ((model.Weather[0].Id >= 300 && model.Weather[0].Id < 400) || model.Weather[0].Id == 500 || model.Weather[0].Id == 501)
         this.Phrase.Value = "get your\n<blue>f*****g</blue> umbrella.";
     else if ((model.Weather[0].Id >= 200 && model.Weather[0].Id < 300) || (model.Weather[0].Id > 501 && model.Weather[0].Id < 600))
         this.Phrase.Value = "it's\n<blue>f*****g</blue> raining\nnow.";
     else if (model.Weather[0].Id >= 600 && model.Weather[0].Id < 700)
         this.Phrase.Value = "freezing\ncold\nlike a\n<red>f*****g</red>\nfridge.";
     else if (model.Weather[0].Id >= 801 && model.Weather[0].Id < 900)
         this.Phrase.Value = "just\n<gray>f*****g</gray> gray.";
     else if (model.Weather[0].Id >= 900 && model.Weather[0].Id < 1000)
         this.Phrase.Value = "better stay\nat your\n<red>f*****g</red> home.";
     else
         this.Phrase.Value = "meh...\njust stay\n<blue>in bed</red>.";
 }
Example #35
0
        private static string GetPhraseResource(CurrentWeather model)
        {
            if (model.IsCold()) return ColdPhrase;
            if (model.IsHot()) return HotPhrase;
            if (model.IsAGreatDay()) return GreatDayPhrase;
            if (model.IsGreat()) return GreatPhrase;
            if (model.IsDrizzling()) return TinyRainPhrase;
            if (model.IsRaining()) return RainingPhrase;
            if (model.IsGray()) return GrayPhrase;
            if (model.IsReallyBad()) return ReallyBadPhrase;

            return DefaultPhrase;
        }