private void TogglePlantingDay()
        {
            //
            // instantiate a responseBusiness class and pass the repository into it
            //
            ResponseBusiness responseBusiness = new ResponseBusiness(responseRepository);
            Response         response;

            using (responseBusiness)
            {
                //TODO: View: update the planting day according to which day was clicked
                //responseBusiness.TogglePlantingDay(event handler?);
                responseBusiness.TogglePlantingDay(1);
                responseBusiness.Save();
            }

            //TODO: View: display the updated planting days dynamically
        }
Beispiel #2
0
        /// <summary>
        /// Iterate through the calendar and find the picture box that matches the sender (the clicked object), and then change that forecast day's IsPlantingDay bool, and updates the picture to reflect that change
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="response"></param>
        private void TogglePlantingDay(object sender, Response response)
        {
            int indexR = 0;

            for (int r = 0; r < tblFreshAPI.RowCount; r++)
            {
                for (int c = 0; c < tblFreshAPI.ColumnCount; c++)
                {
                    Control control = tblFreshAPI.GetControlFromPosition(c, r);

                    Forecastday fd = response.Forecast.Simpleforecast.Forecastdays.Forecastday[indexR];

                    if (control is PictureBox)
                    {
                        PictureBox currentPB = control as PictureBox;

                        if (currentPB == sender)
                        {
                            ResponseBusiness responseBusiness = new ResponseBusiness(_responseRepository);

                            using (responseBusiness)
                            {
                                responseBusiness.TogglePlantingDay(fd.Period);
                            }
                        }
                    }

                    indexR += 1;

                    if (c == 4)
                    {
                        if (r == 0)
                        {
                            indexR = 0;
                        }
                        else if (r == 2)
                        {
                            indexR = 5;
                        }
                    }
                }
            }
        }