private void refreshPossibleSchedulingDates(List <int> FacilitatorFilterList = null, List <int> OnSiteVenueFilterList = null, List <int> OffSiteFitlerList = null, int OffSiteID = 0)
        {
            Common.EnumPreLoadType TypeOfLoading = Common.EnumPreLoadType.PreloadingOnSite;
            if (CurrentScheduleConfiguration.ScheduleLocationID == (int)EnumScheduleLocations.OffSite)
            {
                TypeOfLoading = Common.EnumPreLoadType.PreLoadingOffSite;
            }
            CourseAvailablePeriod ScheduleAlgorthim = new CourseAvailablePeriod(
                CourseSearchPeriodStartDate: dtScheduleFromCustomStartDateSelector.SelectionRange.Start.Date,
                CourseSearchPeriodEndDate: dtScheduleFromCustomStartDateSelector.SelectionRange.Start.AddMonths((int)CurrentPeriodAhead).Date,
                CourseID: CurrentSelectedCurriculumCourseEnrollment.CurriculumCourse.CourseID,
                CourseDescription: CurrentSelectedCurriculumCourseEnrollment.CurriculumCourse.Course.CourseName,
                CourseDuration: CurrentSelectedCurriculumCourseEnrollment.CurriculumCourse.Duration,
                SetOfDaysOfWeekCourseCanBeScheulded: GetDayThatCurriculumCourseCanBeScheduled(),
                PreLoadingType: TypeOfLoading,
                FacilitatorFilterList: FacilitatorFilterList,
                OnSiteFilterList: OnSiteVenueFilterList,
                OffSiteFilterList: OffSiteFitlerList,
                OffSiteID: OffSiteID);//Company ID

            switch ((EnumScheduleLocations)CurrentScheduleConfiguration.ScheduleLocationID)
            {
            case (EnumScheduleLocations.Onsite):
                availableOnSitePeriodsBindingSource.DataSource = ScheduleAlgorthim.GetAllAvailableOnStiePeriods().OrderBy(a => a.CourseStartDate).ThenBy(a => a.FacilitatorName).ToList();
                populateOnsiteFilters(ScheduleAlgorthim);
                break;

            case (EnumScheduleLocations.OffSite):
                availableOffSitePeriodsBindingSource.DataSource = ScheduleAlgorthim.GetAllAvailableOffSitePeriods().OrderBy(a => a.CourseStartDate).ThenBy(a => a.FacilitatorName).ToList();
                populateOffSiteFilters(ScheduleAlgorthim);
                break;
            }
        }
 private void populateOffSiteFilter(CourseAvailablePeriod ScheduleAlgorthim)
 {
     addressBindingSourceFilterList.DataSource = ScheduleAlgorthim.AvailableOffSiteVenues;
 }
 private void populateOffSiteFilters(CourseAvailablePeriod ScheduleAlgorthim)
 {
     this.populateFacilitatorFilter(ScheduleAlgorthim);
     this.populateOffSiteFilter(ScheduleAlgorthim);
 }
 private void populateFacilitatorFilter(CourseAvailablePeriod ScheduleAlgorthim)
 {
     individualBindingSource.DataSource = ScheduleAlgorthim.AvailableFacilitators;
 }
        private void frmPreCalculationTest_Load(object sender, EventArgs e)
        {
            DateTime dt = new DateTime(2017, 07, 19);
            //dt = dt.AddDays(-30);
            //CourseAvailablePeriodByFacilitator xxx = new CourseAvailablePeriodByFacilitator(SearchTimeAhead.OneMonth,dt.Date,4);
            CourseAvailablePeriod xx = new CourseAvailablePeriod(dt, new DateTime(2017, 08, 01), 4, "Orientation", 2,
                                                                 EnumPreLoadType.PreloadingOnSite
                                                                 , new List <EnumDayOfWeeks> {
                EnumDayOfWeeks.Monday,
                EnumDayOfWeeks.Tuesday,
                EnumDayOfWeeks.Wednesday,
                EnumDayOfWeeks.Thursday,
                EnumDayOfWeeks.Friday
            },
                                                                 null,
                                                                 null,
                                                                 null,
                                                                 2004);

            txtOutput.Text += "Booked Facilitator Dates:\n\n";
            foreach (FacilitatorPeriod aa in xx.FacilitatorBookedPeriods)
            {
                txtOutput.Text += "Facilitator ID : " + aa.FacillitatorID.ToString() + " Facilitator Name  " + aa.FacilitatorName + " - StartDate: " + aa.StartDate + " - EndDate: " + aa.EndDate + "\n";
            }
            txtOutput.Text += "\nAvailalble Facilitator Dates:\n\n";
            foreach (FacilitatorPeriod aa in xx.FacilitatorAvailablePeriods)
            {
                txtOutput.Text += "Facilitator ID : " + aa.FacillitatorID.ToString() + " Facilitator Name  " + aa.FacilitatorName + " - StartDate: " + aa.StartDate + " - EndDate: " + aa.EndDate + "\n";
            }

            txtOutput.Text += "\n Booked OnSiteVenue Dates:\n\n";
            foreach (OnSiteVenuePeriod aa in xx.OnSiteVenueBookedPeriods)
            {
                txtOutput.Text += "Venue ID : " + aa.VenueID.ToString() + " Venue Name  " + aa.VenueName + " - StartDate: " + aa.StartDate + " - EndDate: " + aa.EndDate + "\n";
            }


            txtOutput.Text += "\n Available OnSite Venue Dates:\n\n";
            foreach (OnSiteVenuePeriod aa in xx.OnSiteVenueAvailablePeriods)
            {
                txtOutput.Text += "Venue ID : " + aa.VenueID.ToString() + " Venue Name  " + aa.VenueName + " - StartDate: " + aa.StartDate + " - EndDate: " + aa.EndDate + "\n";
            }

            txtOutput.Text += "\n Booked OffSiteVenue Dates:\n\n";
            foreach (OffSiteVenuePeriod aa in xx.OffSiteVenueBookedPeriods)
            {
                txtOutput.Text += "Venue ID : " + aa.VenueID.ToString() + " Venue Name  " + aa.VenueName + " - StartDate: " + aa.StartDate + " - EndDate: " + aa.EndDate + "\n";
            }


            txtOutput.Text += "\n Available OffSite Venue Dates:\n\n";
            foreach (OffSiteVenuePeriod aa in xx.OffSiteVenueAvailablePeriods)
            {
                txtOutput.Text += "Venue ID : " + aa.VenueID.ToString() + " Venue Name  " + aa.VenueName + " - StartDate: " + aa.StartDate + " - EndDate: " + aa.EndDate + "\n";
            }

            //txtOutput.Text += "\n Available Dates that Each Ailitator Can Be Scheduled For a Course:\n\n";
            //foreach (AvailableCoursePeriodByFacilitatorResultSet aa in xx.ListOfAvailableCoursePeriodByFacilitator)
            //{
            //    txtOutput.Text += "Facilitator ID : " + aa.FacilitatorID.ToString() + " Facilitator Name  " + aa.FacilitatorName + "Course ID " + aa.CourseID + " Course Name " + aa.CourseName + " - StartDate: " + aa.CourseStartDate + " - EndDate: " + aa.CourseEndDate + "\n";
            //}
            txtOutput.Text += "\nFINAL OUTPUT DATA SET: Available Facilitator Dates For Course Filtered by - FACILITATOR, Course : \n\n";
            foreach (AvailableCoursePeriodByFacilitatorResultSet ACPBFRS in xx.ListOfAvailableCoursePeriodByFacilitator)
            {
                txtOutput.Text += "Facilitator ID : " + ACPBFRS.FacilitatorID.ToString() + " Facilitator Name  " + ACPBFRS.FacilitatorName + "\nCourse ID " + ACPBFRS.CourseID + " Course Name " + ACPBFRS.CourseName + "\nStartDate: " + ACPBFRS.CourseStartDate + "\nEndDate: " + ACPBFRS.CourseEndDate + "\n-------------------------------------\n";
            }

            txtOutput.Text += "\nFINAL OUTPUT DATA SET: Available Course Filtered by - FACILITATOR, VENUE : \n\n";
            foreach (AvailableOnSitePeriods AOSP in xx.GetAllAvailableOnStiePeriods())
            {
                txtOutput.Text += "Facilitator ID : " + AOSP.FacilitatorID.ToString() + " Facilitator Name  " + AOSP.FacilitatorName + "\nCourse ID " + AOSP.CourseID + " Course Name " + AOSP.CourseName + "\nStartDate: " + AOSP.CourseStartDate + "\nEndDate: " + AOSP.CourseEndDate + "\nVenue ID : " + AOSP.VenueID.ToString() + " Venue Name  " + AOSP.VenueName + "\n-------------------------------------\n";
            }
            //SchedulingDateSearchAlgorithms ScheduleAlgorthim = new SchedulingDateSearchAlgorithms(
            //    CourseIDBookingFor: 4,
            //    InitialDateToStartFrom: dt.Date,
            //     AmountOfSearchTimeAhead: SearchTimeAhead.OneMonth,
            //     CurriculumCourseID: 4117,
            //     ScheduleLocation: Common.Enum.EnumScheduleLocations.Onsite
            //    );
            //List<AvailableOnSitePeriods> kkkkk =  xx.GetAllAvailableOnStiePeriodsV1();
            dataGridView1.DataSource = xx.GetAllAvailableOnStiePeriods()
                                       .OrderBy(a => a.FacilitatorName)
                                       //.ThenBy(a => a.CourseEndDate)
                                       .ThenBy(a => a.CourseStartDate).ToList();
            dataGridView2.DataSource = xx.GetAllAvailableOffSitePeriods()
                                       .OrderBy(a => a.FacilitatorName)
                                       //.ThenBy(a => a.CourseEndDate)
                                       .ThenBy(a => a.CourseStartDate).ToList();

            CourseAvailablePeriod ScheduleAlgorthim = new CourseAvailablePeriod(
                CourseSearchPeriodStartDate: Common.CustomDateTime.getCustomDateTime(
                    CurrentDate: new DateTime(2017, 07, 01),
                    AmountDaysToAdd: 2,

                    DaysCanSchedule: new List <EnumDayOfWeeks> {
                EnumDayOfWeeks.Monday,
                EnumDayOfWeeks.Tuesday,
                EnumDayOfWeeks.Wednesday,
                EnumDayOfWeeks.Thursday
            }),

                CourseSearchPeriodEndDate: new DateTime(2017, 08, 01),
                CourseID: 4,
                CourseDescription: "Orientation",
                CourseDuration: 2,
                PreLoadingType: EnumPreLoadType.PreloadingOnSite,
                SetOfDaysOfWeekCourseCanBeScheulded: new List <EnumDayOfWeeks> {
                EnumDayOfWeeks.Monday,
                EnumDayOfWeeks.Tuesday,
                EnumDayOfWeeks.Wednesday,
                EnumDayOfWeeks.Thursday
            },
                OffSiteID: 2004);

            //availableOnSitePeriodsBindingSource.DataSource = ScheduleAlgorthim.GetAllAvailableOnStiePeriods();
            //dataGridView1.DataSource = aa.CourseByFacilitatorAvailableDateSets;
            //txtOutput.Text += "Booked Facilitator Dates:\n\n";
            //foreach (FacilitatorBookedDateSet aa in ScheduleAlgorthim.FacilitatorBookedDateSets)
            //{
            //    txtOutput.Text += aa.FacilitatorID.ToString() + " - StartDate: " + aa.StartDate + " - EndDate: " + aa.EndDate + "\n";
            //}
            //txtOutput.Text += "Available Facilitator Dates:\n\n";
            //foreach (FacilitatorAvailableDateSet aa in ScheduleAlgorthim.FacilitatorAvailableDateSets)
            //{
            //    txtOutput.Text += aa.FacilitatorID.ToString() + " - StartDate: " + aa.StartDate + " - EndDate: " + aa.EndDate + "\n";
            //}
            //txtOutput.Text += "Booked Venues Dates:\n\n";
            //foreach (VenueBookedDateSet aa in ScheduleAlgorthim.VenueBookedDateSets)
            //{
            //    txtOutput.Text += aa.VenueID.ToString() + " - StartDate: " + aa.StartDate + " - EndDate: " + aa.EndDate + "\n";
            //}
            //txtOutput.Text += "Available Venue Dates:\n\n";
            //foreach (VenueAvailableDateSet aa in ScheduleAlgorthim.VenueAvailableDateSets)
            //{
            //    txtOutput.Text += aa.VenueID.ToString() + " - StartDate: " + aa.StartDate + " - EndDate: " + aa.EndDate + "\n";
            //}

            //txtOutput.Text += "Available Course By Facilitator Dates:\n\n";
            //foreach (CourseByFacilitatorAvailableDateSet aa in ScheduleAlgorthim.CourseByFacilitatorAvailableDateSets)
            //{
            //    txtOutput.Text += "FacilitatorID: " + aa.FacilitatorID.ToString() + "CurriculumCourseID: " + aa.CurriculumCourseID + " - StartDate: " + aa.StartDate + " - EndDate: " + aa.EndDate + "\n";
            //}

            //txtOutput.Text += "Available Course By Facilitator AND Venue Dates:\n\n";
            //foreach (CourseByFacilitatorAndVenueAvailableDateSet aa in ScheduleAlgorthim.CourseByFacilitatorAndVenueAvailableDateSets)
            //{
            //    txtOutput.Text += "FacilitatorID: " + aa.FacilitatorID.ToString() + " VenueID: " + aa.VenueID.ToString() + "CurriculumCourseID: " + aa.CurriculumCourseID + " - StartDate: " + aa.StartDate + " - EndDate: " + aa.EndDate + "\n";
            //}
        }