/// <summary>
        ///  Add Staff CourseSection Schedule
        /// </summary>
        /// <param name="staffScheduleViewModel"></param>
        /// <returns></returns>
        public StaffScheduleViewModel AddStaffCourseSectionSchedule(StaffScheduleViewModel staffScheduleViewModel)
        {
            try
            {
                if (staffScheduleViewModel.staffScheduleViewList.Count() > 0)

                {
                    foreach (var staffSchedule in staffScheduleViewModel.staffScheduleViewList.ToList())
                    {
                        var courseSectionList = staffSchedule.courseSectionViewList.ToList();

                        if (courseSectionList.Count > 0)
                        {
                            foreach (var CourseSection in courseSectionList)
                            {
                                var staffCoursesectionSchedule = new StaffCoursesectionSchedule()
                                {
                                    TenantId             = staffScheduleViewModel.TenantId,
                                    SchoolId             = staffScheduleViewModel.SchoolId,
                                    StaffId              = staffSchedule.StaffId,
                                    CourseId             = (int)CourseSection.CourseId,
                                    CourseSectionId      = (int)CourseSection.CourseSectionId,
                                    StaffGuid            = (Guid)staffSchedule.StaffGuid,
                                    CourseSectionName    = CourseSection.CourseSectionName,
                                    YrMarkingPeriodId    = CourseSection.YrMarkingPeriodId,
                                    SmstrMarkingPeriodId = CourseSection.SmstrMarkingPeriodId,
                                    QtrMarkingPeriodId   = CourseSection.QtrMarkingPeriodId,
                                    DurationStartDate    = CourseSection.DurationStartDate,
                                    DurationEndDate      = CourseSection.DurationEndDate,
                                    MeetingDays          = CourseSection.MeetingDays,
                                    CreatedBy            = staffScheduleViewModel.CreatedBy,
                                    CreatedOn            = DateTime.UtcNow,
                                    IsAssigned           = true
                                };
                                this.context?.StaffCoursesectionSchedule.Add(staffCoursesectionSchedule);
                            }
                            this.context?.SaveChanges();
                            staffScheduleViewModel._message = "Staff CourseSection Schedule Added Successfully";
                            staffScheduleViewModel._failure = false;
                        }
                        else
                        {
                            staffScheduleViewModel._failure = true;
                            staffScheduleViewModel._message = "Select CourseSection For CourseSection Schedule";
                        }
                    }
                }
                else
                {
                    staffScheduleViewModel._failure = true;
                    staffScheduleViewModel._message = "Select Staff For CourseSection Schedule";
                }
            }
            catch (Exception es)
            {
                staffScheduleViewModel._failure = true;
                staffScheduleViewModel._message = es.Message;
            }
            return(staffScheduleViewModel);
        }
        /// <summary>
        /// Add Staff CourseSection Re-Schedule By Course Wise
        /// </summary>
        /// <param name="staffListViewModel"></param>
        /// <returns></returns>
        public StaffListViewModel AddStaffCourseSectionReScheduleByCourse(StaffListViewModel staffListViewModel)
        {
            try
            {
                if (staffListViewModel.courseSectionsList.Count() > 0)
                {
                    var staffGuid = this.context.StaffMaster.Where(x => x.StaffId == staffListViewModel.ReScheduleStaffId && x.SchoolId == staffListViewModel.SchoolId && x.TenantId == staffListViewModel.TenantId).FirstOrDefault().StaffGuid;

                    foreach (var courseSection in staffListViewModel.courseSectionsList.ToList())
                    {
                        var StaffScheduleData = this.context.StaffCoursesectionSchedule.FirstOrDefault(x => x.TenantId == staffListViewModel.TenantId && x.SchoolId == staffListViewModel.SchoolId && x.StaffId == courseSection.StaffCoursesectionSchedule.FirstOrDefault().StaffId&& x.CourseSectionId == courseSection.CourseSectionId);

                        if (StaffScheduleData != null)
                        {
                            StaffScheduleData.IsDropped         = true;
                            StaffScheduleData.EffectiveDropDate = DateTime.UtcNow;
                        }
                        else
                        {
                            staffListViewModel._failure = true;
                            staffListViewModel._message = "Exixting Staff Does't in this CourseSection";
                            return(staffListViewModel);
                        }

                        var staffCoursesectionSchedule = new StaffCoursesectionSchedule()
                        {
                            TenantId             = (Guid)staffListViewModel.TenantId,
                            SchoolId             = (int)staffListViewModel.SchoolId,
                            StaffId              = (int)staffListViewModel.ReScheduleStaffId,
                            CourseId             = courseSection.CourseId,
                            CourseSectionId      = courseSection.CourseSectionId,
                            StaffGuid            = staffGuid,
                            CourseSectionName    = courseSection.CourseSectionName,
                            YrMarkingPeriodId    = courseSection.YrMarkingPeriodId,
                            SmstrMarkingPeriodId = courseSection.SmstrMarkingPeriodId,
                            QtrMarkingPeriodId   = courseSection.QtrMarkingPeriodId,
                            DurationStartDate    = courseSection.DurationStartDate,
                            DurationEndDate      = courseSection.DurationEndDate,
                            MeetingDays          = courseSection.StaffCoursesectionSchedule.FirstOrDefault().MeetingDays,
                            CreatedBy            = staffListViewModel.CreatedBy,
                            CreatedOn            = DateTime.UtcNow,
                            IsAssigned           = true
                        };
                        this.context?.StaffCoursesectionSchedule.Add(staffCoursesectionSchedule);
                    }
                    this.context?.SaveChanges();
                    staffListViewModel._message = "Staff  Re-Schedule In CourseSection Successfully";
                    staffListViewModel._failure = false;
                }
                else
                {
                    staffListViewModel._failure = true;
                    staffListViewModel._message = "Select CourseSection For Staff  Re-Schedule";
                }
            }
            catch (Exception es)
            {
                staffListViewModel._failure = true;
                staffListViewModel._message = es.Message;
            }
            return(staffListViewModel);
        }