Beispiel #1
0
        /// <summary>
        /// the event handler for all picture boxes in the table layout panel calendar that allows the user to toggle back and forth between having a day be a planting day or not
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void CommonClick_TogglePlantingDay(object sender, EventArgs e)
        {
            ResponseBusiness responseBusiness = new ResponseBusiness(_responseRepository);
            Response         response;

            using (responseBusiness)
            {
                response = responseBusiness.SelectAll();
            }

            PictureBox picture = sender as PictureBox;

            TogglePlantingDay(sender, response);

            responseBusiness = null;

            responseBusiness = new ResponseBusiness(_responseRepository);

            using (responseBusiness)
            {
                response = responseBusiness.SelectAll();
            }

            FillWeatherDays(response, AppEnum.ManagerAction.TogglePlantingDay);
        }
        private void TestingMethods()
        {
            ResponseBusiness responseBusiness = new ResponseBusiness(responseRepository);

            Response response;

            using (responseBusiness)
            {
                response = responseBusiness.SelectAll();
            }

            foreach (var fd in response.Forecast.Simpleforecast.Forecastdays.Forecastday)
            {
                Console.WriteLine(fd.Period);
                Console.WriteLine(fd.Date.Weekday);
                Console.WriteLine(fd.Pop);
                Console.WriteLine(fd.IsPlantingDay);
            }

            ResponseBusiness responseBusiness2 = new ResponseBusiness(responseRepository);
            Forecastday      forecastDay;

            using (responseBusiness2)
            {
                forecastDay = responseBusiness2.SelectByPeriod(1);
            }

            Console.WriteLine($"We found the first day! {forecastDay.Date.Weekday}, {forecastDay.Date.Monthname} {forecastDay.Date.Day}");

            Console.WriteLine("Press any key to exit");

            Console.ReadKey();
        }
        private void TestingAChange()
        {
            ResponseBusiness responseBusiness = new ResponseBusiness(responseRepository);

            Response response;

            using (responseBusiness)
            {
                response = responseBusiness.SelectAll();
            }

            long lengthOfForecast = response.Forecast.Simpleforecast.Forecastdays.Forecastday.LongCount();

            long oneLessThanFullList = lengthOfForecast - 1;

            for (long index = 0; index < oneLessThanFullList; index++)
            {
                if (response.Forecast.Simpleforecast.Forecastdays.Forecastday[(int)index + 1].Pop >= 50)
                {
                    response.Forecast.Simpleforecast.Forecastdays.Forecastday[(int)index].IsPlantingDay = true;
                }
            }

            foreach (var fd in response.Forecast.Simpleforecast.Forecastdays.Forecastday)
            {
                Console.WriteLine(fd.Date.Weekday);
                Console.WriteLine(fd.Pop);
                Console.WriteLine(fd.IsPlantingDay);
                Console.WriteLine();
            }
        }
Beispiel #4
0
        /// <summary>
        /// removes all images from the table layout panel for the calendar, but keeps the days of the week visible
        /// </summary>
        private void ClearTable()
        {
            ResponseBusiness responseBusiness = new ResponseBusiness(_responseRepository);
            Response         response;

            using (responseBusiness)
            {
                response = responseBusiness.SelectAll();
            }

            FillWeatherDays(response, AppEnum.ManagerAction.CalendarOnly);
        }
Beispiel #5
0
        /// <summary>
        /// instantiates a business repository and uses that to apply the business logic for planting days, and saves that business repository to a reponse object, and passes that into the method that fills the table layout panel calendar with weather and planting days both
        /// </summary>
        private void AutoFillPlantingDays()
        {
            ResponseBusiness responseBusiness = new ResponseBusiness(_responseRepository);
            Response         response;

            using (responseBusiness)
            {
                responseBusiness.AutoFillPlantingDays();
                response = responseBusiness.SelectAll();
            }

            FillWeatherDays(response, AppEnum.ManagerAction.AutoFillPlantingDays);
        }
Beispiel #6
0
        /// <summary>
        /// Fills the calendar with icons for the weather
        /// </summary>
        private void SetWeatherIcons()
        {
            ResponseBusiness responseBusiness = new ResponseBusiness(_responseRepository);
            Response         response;


            using (responseBusiness)
            {
                response = responseBusiness.SelectAll();
            }

            FillWeatherDays(response, AppEnum.ManagerAction.GetWeather);
        }
Beispiel #7
0
        /// <summary>
        /// Define a response object from the repository and use it to fill the calendar with the names of the days of the week, but nothing else
        /// </summary>
        private void SetBlankCalendar()
        {
            // get the weather, but only display the days for now
            // b/c more fun for a user to see the process from blank calendar to
            // a calendar filled with weather icons
            ResponseBusiness responseBusiness = new ResponseBusiness(_responseRepository);
            Response         response;

            using (responseBusiness)
            {
                response = responseBusiness.SelectAll();
            }

            FillWeatherDays(response, AppEnum.ManagerAction.CalendarOnly);
        }
        private void GetWeather()
        {
            //
            // instantiate a responseBusiness class and pass the repository into it
            //
            ResponseBusiness responseBusiness = new ResponseBusiness(responseRepository);
            Response         response;

            using (responseBusiness)
            {
                responseBusiness.AssignIsRainyDay();
                response = responseBusiness.SelectAll();
                //TODO: View: display fresh API pull form
            }
        }