// GET: Admin/Delete/5 public ActionResult DeleteCourseTime(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CourseTimetable courseTimetable = db.CourseTimetables.SingleOrDefault(ct => ct.CourseTimetableId == id); Courses courses = db.Courses.SingleOrDefault(c => c.CoursesID == courseTimetable.CoursesID); if (courseTimetable == null) { return(HttpNotFound()); } TimetableVM timetable = new TimetableVM { //CoursesID = courses.CoursesID, CourseName = courses.CourseName, CourseTimetableId = courseTimetable.CourseTimetableId, //Programme = courses.Programme, StartTime = courseTimetable.StartTime.ToString(), EndTime = courseTimetable.EndTime.ToString(), }; return(View(timetable)); }
public ActionResult CheckIn(string CourseName) { List <TimetableVM> getTimetable = new List <TimetableVM>(); var getCourse = db.Courses.SingleOrDefault(c => c.CourseName == CourseName); var getTime = db.CourseTimetables.Where(c => c.CoursesID == getCourse.CoursesID); foreach (var item in getTime) { if (getTime == null) { string Error = "No Data"; return(Json(new { Error, time = false }, JsonRequestBehavior.AllowGet)); } TimetableVM AddTimetable = new TimetableVM { CoursesID = item.CoursesID, CourseTimetableId = item.CourseTimetableId, CourseName = getCourse.CourseName, Programme = getCourse.Programme, StartTime = item.StartTime.ToString(), EndTime = item.EndTime.ToString() }; getTimetable.Add(AddTimetable); } return(Json(new { getTimetable, time = true }, JsonRequestBehavior.AllowGet)); //Session["SelectedCourse"] = selected.CourseName; //return RedirectToAction("CourseDateIndex"); }
public ActionResult CourseIndex(int CourseId, string selectedProgramme) { List <TimetableVM> getTimetable = new List <TimetableVM>(); /* string programme = Session["SelectedProgramme"].ToString()*/ //var courseTimetable = db.Courses.ToList().Where(c => c.Programme == (Programme)Enum.Parse(typeof(Programme), selectedProgramme) && c.CourseName == selectedCourse); var programme = (Programme)Enum.Parse(typeof(Programme), selectedProgramme); var getCourse = db.Courses.SingleOrDefault(c => c.CoursesID == CourseId && c.Programme == programme); var getTime = db.CourseTimetables.Where(c => c.CoursesID == getCourse.CoursesID); foreach (var item in getTime) { if (getTime == null) { string Error = "No Data"; return(Json(new { Error, time = false }, JsonRequestBehavior.AllowGet)); } TimetableVM AddTimetable = new TimetableVM { CoursesID = item.CoursesID, CourseTimetableId = item.CourseTimetableId, CourseName = getCourse.CourseName, Programme = getCourse.Programme, StartTime = item.StartTime.ToString(), EndTime = item.EndTime.ToString() }; getTimetable.Add(AddTimetable); } return(Json(new { getTimetable, time = true }, JsonRequestBehavior.AllowGet)); }
public ActionResult CourseIndex(string SelectedOption, int CourseId, string selectedProgramme, string StudentName) { List <TimetableVM> getData = new List <TimetableVM>(); if (SelectedOption == "Course" && StudentName == "") { /* string programme = Session["SelectedProgramme"].ToString()*/ //var courseTimetable = db.Courses.ToList().Where(c => c.Programme == (Programme)Enum.Parse(typeof(Programme), selectedProgramme) && c.CourseName == selectedCourse); var programme = (Programme)Enum.Parse(typeof(Programme), selectedProgramme); var getCourse = db.Courses.SingleOrDefault(c => c.CoursesID == CourseId && c.Programme == programme); var getTime = db.CourseTimetables.Where(c => c.CoursesID == getCourse.CoursesID); int TotalCourseTime = 0; if (getTime.Count() == 0) { string Error = "This course haven't create a timetable"; return(Json(new { Error, time = false }, JsonRequestBehavior.AllowGet)); } foreach (var item in getTime) { TimetableVM AddTimetable = new TimetableVM { CoursesID = item.CoursesID, CourseTimetableId = item.CourseTimetableId, CourseName = getCourse.CourseName, Programme = getCourse.Programme, StartTime = item.StartTime.ToString(), EndTime = item.EndTime.ToString() }; getData.Add(AddTimetable); } TotalCourseTime = getTime.Count(); return(Json(new { TotalCourseTime, getData, time = true }, JsonRequestBehavior.AllowGet)); } else if (SelectedOption == "Student" && StudentName == "") { var programme = (Programme)Enum.Parse(typeof(Programme), selectedProgramme); var getCourse = db.Users.Where(c => c.Programme == programme); int TotalStudent = getCourse.Count(); if (getCourse.Count() == 0) { string Error = "No Data"; return(Json(new { Error, time = false }, JsonRequestBehavior.AllowGet)); } foreach (var item in getCourse) { TimetableVM AddNameList = new TimetableVM { StudentName = item.Username, StudentID = item.UsersID }; getData.Add(AddNameList); } return(Json(new { TotalStudent, getData, time = true }, JsonRequestBehavior.AllowGet)); } return(Json(new { time = false }, JsonRequestBehavior.AllowGet)); }
public ActionResult SelectProgramme(string selectedProgramme) { List <TimetableVM> AllCourseName = new List <TimetableVM>(); var Getdata = db.Courses.ToList().Where(c => c.Programme == (Programme)Enum.Parse(typeof(Programme), selectedProgramme)); foreach (var item in Getdata) { var check = AllCourseName.SingleOrDefault(a => a.CourseName == item.CourseName); if (check == null) { TimetableVM AddCourseName = new TimetableVM { CoursesID = item.CoursesID, CourseName = item.CourseName, }; AllCourseName.Add(AddCourseName); } } return(Json(new { AllCourseName, data = true }, JsonRequestBehavior.AllowGet)); //Session["SelectedProgramme"] = selected.Programmes.ToString(); //return RedirectToAction("CourseIndex"); }
public ActionResult CheckAttendance(string CourseName) { List <TimetableVM> getTimetable = new List <TimetableVM>(); var id = Convert.ToInt32(Session["Student"]); var Users = db.Users.SingleOrDefault(c => c.UsersID == id); var Attendance = db.Attendance.Where(c => c.Name == Users.Username).ToList(); var getCourse = db.Courses.SingleOrDefault(c => c.CourseName == CourseName && c.Programme == Users.Programme); var getTime = db.CourseTimetables.Where(c => c.CoursesID == getCourse.CoursesID); string Check = ""; string CheckAttendanceTime = ""; int TotalCourseTime = 0; int TotalCheckedIn = 0; if (CourseName == "--Select Course--") { return(Json(new { course = false }, JsonRequestBehavior.AllowGet)); } if (getCourse == null) { return(RedirectToAction("CheckIn")); } if (getTime.Count() == 0) { string Error = "This course haven't create a timetable"; return(Json(new { Error, time = false }, JsonRequestBehavior.AllowGet)); } foreach (var item in getTime) { var checkAttendance = Attendance.SingleOrDefault(c => c.CourseTimetableId == item.CourseTimetableId); if (checkAttendance != null) { Check = "Checked In"; CheckAttendanceTime = checkAttendance.AttendanceTime.ToString(); TotalCheckedIn++; } else { Check = "No Check In"; CheckAttendanceTime = "No Check In"; } TimetableVM AddTimetable = new TimetableVM { CoursesID = item.CoursesID, CourseTimetableId = item.CourseTimetableId, CourseName = getCourse.CourseName, Programme = getCourse.Programme, StartTime = item.StartTime.ToString(), EndTime = item.EndTime.ToString(), AttendanceTime = CheckAttendanceTime, CheckInButton = Check }; getTimetable.Add(AddTimetable); } TotalCourseTime = getTimetable.Count(); return(Json(new { TotalCheckedIn, TotalCourseTime, getTimetable, time = true }, JsonRequestBehavior.AllowGet)); //Session["SelectedCourse"] = selected.CourseName; //return RedirectToAction("CourseDateIndex"); }
public ActionResult CheckAllStudentAttendance(int Dataid, string GetSelectedProgramme, string SelectedOption, string GetSelectedCourse) { List <TimetableVM> getStudentAttendance = new List <TimetableVM>(); var getAllStudent = db.Users.Where(c => c.Roles == Roles.Student).ToList(); var getAllCourseTime = db.CourseTimetables.Where(c => c.CoursesID.ToString() == GetSelectedCourse).ToList(); var getStudent = db.Users.SingleOrDefault(c => c.UsersID == Dataid); if (getAllCourseTime.Count() == 0) { string Error = "This course haven't create a timetable"; return(Json(new { Error, notime = true }, JsonRequestBehavior.AllowGet)); } string Status = ""; string CheckAttendanceTime = ""; int TotalCourseTime = 0; int TotalCheckedIn = 0; int TotalStudent = getAllStudent.Count(); if (SelectedOption == "Course") { foreach (var item in getAllStudent) { var getCourseTime = db.Attendance.Where(c => c.CourseTimetableId == Dataid && c.Name == item.Username).SingleOrDefault(); if (getCourseTime != null) { Status = "Checked In"; CheckAttendanceTime = getCourseTime.AttendanceTime.ToString(); TotalCheckedIn++; } else { Status = "No Check In"; CheckAttendanceTime = "No Check In"; } TimetableVM AddTimetable = new TimetableVM { StudentName = item.Username, CheckInButton = Status, AttendanceTime = CheckAttendanceTime }; getStudentAttendance.Add(AddTimetable); } return(Json(new { TotalCheckedIn, TotalStudent, getStudentAttendance, time = false }, JsonRequestBehavior.AllowGet)); } else if (SelectedOption == "Student") { foreach (var item in getAllCourseTime) { var checkStudentAttendance = db.Attendance.Where(c => c.CourseTimetableId == item.CourseTimetableId && c.Name == getStudent.Username).SingleOrDefault(); if (checkStudentAttendance != null) { Status = "Checked In"; CheckAttendanceTime = checkStudentAttendance.AttendanceTime.ToString(); TotalCheckedIn++; } else { Status = "No Check In"; CheckAttendanceTime = "No Check In"; } TimetableVM AddTimetable = new TimetableVM { StartTime = item.StartTime.ToString(), EndTime = item.EndTime.ToString(), CheckInButton = Status, AttendanceTime = CheckAttendanceTime }; getStudentAttendance.Add(AddTimetable); } TotalCourseTime = getAllCourseTime.Count(); return(Json(new { TotalCourseTime, TotalCheckedIn, getStudentAttendance, time = false }, JsonRequestBehavior.AllowGet)); } return(Json(new { time = false }, JsonRequestBehavior.AllowGet)); }