Example #1
0
        static void Main()
        {
            //Initialize : get and return weather status/rating for dogs
            //Then send sms message to user
            WeatherRating weatherRating = new WeatherRating();
            MessagingAPI  messagingApi  = new MessagingAPI();

            //Main execution
            messagingApi.SendMessage(weatherRating.WeatherRatingPrint());

            //weatherRating.WeatherRatingPrint();
        }
Example #2
0
        public string WeatherRatingPrint()
        {
            //get the payload from api
            var payload = new WeatherRating().LoadPayload();

            //initialize the payload for consumption
            ForecastResponse forecastResponse = JsonConvert.DeserializeObject <ForecastResponse>(payload);
            //create Lists for temp and precip
            List <decimal> temperatureArray = new List <decimal>();
            List <double>  precipArray      = new List <double>();

            //store next 10 hours of weather data
            // both temperature and precipitation probability
            for (int i = 0; i < 10; i++)
            {
                temperatureArray.Add(forecastResponse.hourly.data[i].temperature);
                precipArray.Add(forecastResponse.hourly.data[i].precipProbability);
                Console.WriteLine(UnixTimeStampToDateTime(forecastResponse.hourly.data[i].time));
                //Console.WriteLine(forecastResponse.hourly.data[i].temperature);
                //Console.WriteLine(forecastResponse.hourly.data[i].precipProbability);
            }
            Console.WriteLine("===========================");
            temperatureArray.ForEach(Console.WriteLine);
            Console.WriteLine("===========================");
            precipArray.ForEach(Console.WriteLine);
            Console.WriteLine("===========================");

            //Call average temperature ratin method
            decimal tempAverage = temperatureArray.Average();

            Console.WriteLine("This is your temperature average over the next 10 hours " + tempAverage);

            //Call average precip rating method
            double precipAverage = precipArray.Average();

            Console.WriteLine("This is your precipitation probability average over the next 10 hours " + precipAverage);

            Console.WriteLine(DogSafetyCheck(tempAverage, precipAverage));
            return(DogSafetyCheck(tempAverage, precipAverage));
        }