private bool existScheduleConflictGroupWithoutGroupSelect(int pProfessorID, int pGroupID, int pPeriodID)
        {
            /*Get Group from database accordin to pGroupID*/
            var vListScheduleGroup = (from grupo in db.Groups
                                      join grupo_aula in db.GroupClassrooms on grupo.ID equals grupo_aula.GroupID
                                      join horario in db.Schedules on grupo_aula.ScheduleID equals horario.ID
                                      where (grupo.ID == pGroupID)
                                      select new { horario.StartHour, horario.EndHour, horario.Day }).ToList();


            //Get the day, starthour and endhour where professor was assign in commission
            var group_schedule = db.SP_getProfessorScheduleGroup(pProfessorID, pPeriodID).ToList();

            //Verify each scheedule with the new assign information
            foreach (var vNewSchedule in vListScheduleGroup)
            {
                foreach (var vActualScheduleGroup in group_schedule)
                {
                    if (vActualScheduleGroup.ID != pGroupID)
                    {
                        bool vIsScheduleCorrect = verifyRange(vNewSchedule.Day, vActualScheduleGroup.Day, vActualScheduleGroup.StartHour,
                                                              vActualScheduleGroup.EndHour, vNewSchedule.StartHour, vNewSchedule.EndHour);
                        if (vIsScheduleCorrect)
                        {
                            return(vIsScheduleCorrect);
                        }
                    }
                }
            }
            return(false);
        }
示例#2
0
        /// <summary>
        /// Esteban Segura Benavides
        /// Check posibles conflicts with the new project schedule and the all group schedule related with determinated professor
        /// </summary>
        /// <param name="pProfessorID"></param>
        /// <param name="pSchedules"></param>
        /// <returns>true if found any problem with the schedules</returns>
        public bool existShockScheduleGroup(int pProfessorID, List <ScheduleComission> pSchedules)
        {
            var vPeriod   = Request.Cookies["Periodo"].Value;
            var vPeriodID = db.Periods.Find(int.Parse(vPeriod)).ID;

            //Get the day, starthour and endhour where professor was assign in commission
            var project_schedule = db.SP_getProfessorScheduleGroup(pProfessorID, vPeriodID).ToList();

            //Verify each scheedule with the new assign information
            foreach (var vNewSchedule in pSchedules)
            {
                foreach (var vActualScheduleProject in project_schedule)
                {
                    if (vNewSchedule.Day.Equals(vActualScheduleProject.Day))
                    {
                        var vActualStartHour = DateTime.Parse(vActualScheduleProject.StartHour);
                        var vActualEndHour   = DateTime.Parse(vActualScheduleProject.EndHour);
                        var vNewStartHour    = DateTime.Parse(vNewSchedule.StartHour);
                        var vNewEndHour      = DateTime.Parse(vNewSchedule.EndHour);

                        //Check the range of the schedule
                        if ((vActualStartHour <= vNewStartHour && vNewStartHour <= vActualEndHour) ||
                            (vActualStartHour <= vNewEndHour && vNewEndHour <= vActualEndHour) ||
                            (vNewStartHour <= vActualStartHour && vActualStartHour <= vNewEndHour) ||
                            (vNewStartHour <= vActualEndHour && vActualEndHour <= vNewEndHour))
                        {
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }