//public ActionResult CheckSubjectSlotAvialability(string subject, string level, string StartHourclinet, string StartMinuteclinet) public ActionResult CheckDaySlotAvialability(string levels) { //var theValue = $('#Subject').val() + ";" + $('#Class').val() + ";" + $('#StratTimeHour').val() + ";" + $('#StratTimeMinute').val() + ";" + $('#Teacher').val() + ";" + $('#Day').val(); string[] theLEvel = levels.Split(';'); string subject = theLEvel[0]; string level = theLEvel[1]; string StartHourclinet = theLEvel[2]; string StartMinuteclinet = theLEvel[3]; string day1 = theLEvel[5]; // string day1 = theLEvel[5]; Day day = DayHelper.GetDay(day1); smContext db = new smContext(); List <TeachingDay> theTeachingDay = db.TeachingDay.Include("TeachingSubject").Where(a => a.TeachingClass.ClassName == level && a.theDay == day).ToList(); foreach (TeachingDay td in theTeachingDay) { TeachingClass theTeachingClass = db.TeachingClass.Where(a => a.TeachingClassID == td.TeachingClassID).First(); string theClass = theTeachingClass.ClassName; // string theClass = td.TeachingClass.ClassName; foreach (TeachingSubject ts in td.TeachingSubject) { String Day = ts.TeachingDay.theDay.ToString(); string theSubject = ts.SubjectName; string EndHour = ts.TeachingDay.EndTimeHour; string EndMinutes = ts.TeachingDay.EndTimeMinute; string StartHour = ts.TeachingDay.StratTimeHour; string StartMinutes = ts.TeachingDay.StratTimeMinute; StringBuilder EndHourEndMinutes = new StringBuilder(); EndHourEndMinutes.Append(EndHour); EndHourEndMinutes.Append(EndMinutes); int time = Convert.ToInt16(EndHourEndMinutes.ToString()); //= Convert.ToInt16(EndHour) + Convert.ToInt16(EndMinutes); StringBuilder StartHourStartMinuteclinets = new StringBuilder(); StartHourStartMinuteclinets.Append(StartHourclinet).Append(StartMinuteclinet); int timeClient = Convert.ToInt16(StartHourStartMinuteclinets.ToString());//Convert.ToInt16(StartHourclinet) + Convert.ToInt16(StartMinuteclinet); if (timeClient < time) { string theAlert = theSubject + " has been fixed for " + theClass + " which starts " + StartHour + ":" + StartMinutes + " ends at " + EndHour + ":" + EndMinutes; return(Json(theAlert, JsonRequestBehavior.AllowGet)); } } } // } return(Json("", JsonRequestBehavior.AllowGet)); }
//public ActionResult CheckSubjectSlotAvialability(string subject, string level, string StartHourclinet, string StartMinuteclinet) public ActionResult CheckStaffSlotAvialability(string levels) { string[] theLEvel = levels.Split(';'); string subject = theLEvel[0]; string level = theLEvel[1]; string StartHourclinet = theLEvel[2]; string StartMinuteclinet = theLEvel[3]; string teacher = theLEvel[4]; // string[] split = teacher.Split(' '); // int teacherID = Convert.ToInt32(split[0]); string day1 = theLEvel[5]; Day day = DayHelper.GetDay(day1); smContext db = new smContext(); List <Teacher> Teacher = db.Teacher.Include("TheTeachingClass").Where(a => a.TeacherName == teacher).ToList(); foreach (Teacher t in Teacher) { // List<TeachingSubject> theTeachingSubject = work.TeachingSubjectRepository.Get().ToList(); // List<TeachingClass> theTeachingClass = db.TeachingClass.Include("TheTeachingDay").Where(a => a.ClassName == level && a.Teacher.TeacherID == t.TeacherID).ToList(); //work.TeachingClassRepository.Get(a => a.ClassName == level).ToList(); List <TeachingClass> theTeachingClass = db.TeachingClass.Include("TheTeachingDay").Where(a => a.Teacher.TeacherID == t.TeacherID).ToList(); //work.TeachingClassRepository.Get(a => a.ClassName == level).ToList(); foreach (TeachingClass c in theTeachingClass) { string ClassName = c.ClassName; // foreach (TeachingDay td in c.TheTeachingDay) // { List <TeachingDay> theTeachingDay = db.TeachingDay.Include("TeachingSubject").Where(a => a.TeachingClass.TeachingClassID == c.TeachingClassID && a.theDay == day).ToList(); foreach (TeachingDay td in theTeachingDay) { foreach (TeachingSubject ts in td.TeachingSubject) { String Day = ts.TeachingDay.theDay.ToString(); string theSubject = ts.SubjectName; string EndHour = ts.TeachingDay.EndTimeHour; string EndMinutes = ts.TeachingDay.EndTimeMinute; string StartHour = ts.TeachingDay.StratTimeHour; string StartMinutes = ts.TeachingDay.StratTimeMinute; StringBuilder EndHourEndMinutes = new StringBuilder(); EndHourEndMinutes.Append(EndHour); EndHourEndMinutes.Append(EndMinutes); int time = Convert.ToInt16(EndHourEndMinutes.ToString()); //= Convert.ToInt16(EndHour) + Convert.ToInt16(EndMinutes); StringBuilder StartHourStartMinuteclinets = new StringBuilder(); StartHourStartMinuteclinets.Append(StartHourclinet).Append(StartMinuteclinet); int timeClient = Convert.ToInt16(StartHourStartMinuteclinets.ToString());//Conve if (theSubject == subject && timeClient < time) { string theAlert = theSubject + " " + "has been fixed for " + teacher + " on " + Day + " for class " + ClassName + " which starts at " + StartHour + ":" + StartMinutes + " and which ends at " + EndHour + ":" + EndMinutes; return(Json(theAlert, JsonRequestBehavior.AllowGet)); } if (theSubject != subject && timeClient < time) { string theAlert = theSubject + " " + "has been fixed for " + teacher + " on " + Day + " for class " + ClassName + " which starts at " + StartHour + ":" + StartMinutes + " and which ends at " + EndHour + ":" + EndMinutes; // string theAlert = teacher + " " + "has been fixed for this day and ends " + EndHour + ":" + EndMinutes; return(Json(theAlert, JsonRequestBehavior.AllowGet)); } } // tdy.su // theTeachingDay. // foreach(TeachingSubj) } } } return(Json("", JsonRequestBehavior.AllowGet)); }