public ActionResult ChangeStudentGrade() { if ((Request.Form["gridRadios1"] != null) && (Request.Form["Student_id"] != null)) { string student_id = Request.Form["Student_id"]; int course_id = Convert.ToInt32(Request.Form["Course_id"]); int grade = Convert.ToInt32(Request.Form["Grade"]); PDAL DBconnection = new PDAL(); UsersCourses Student = DBconnection.UsersCoursess.Find(student_id, course_id); string option = Request.Form["gridRadios1"].ToString(); if (Student != null) { if (option.Equals("option1")) { Student.moed1 = grade; Student.final = grade; } else if (option.Equals("option2")) { Student.moed2 = grade; Student.final = grade; } else { Student.final = grade; } } DBconnection.SaveChanges(); } return(Redirect("~/Administration/AdminMain")); }
public ActionResult ChangeMoedDate() { try { string date_time = Request.Form["Date"] + Request.Form["Time"]; int cource_id = Convert.ToInt32(Request.Form["Course_id"]); DateTime dt = DateTime.ParseExact(date_time, "dd-MM-yyyyHH:mm", CultureInfo.InvariantCulture); PDAL DBconnection = new PDAL(); Course a = DBconnection.Courses.Find(cource_id); if (a == null) { Session["Alert"] = "No such course."; return(Redirect("~/Administration/AdminMain")); } if (Request.Form["gridRadios1"] == "option1") { a.moed1 = dt; } if (Request.Form["gridRadios1"] == "option2") { a.moed2 = dt; } DBconnection.SaveChanges(); } catch { Session["Alert"] = "Bad time or date format."; } return(Redirect("~/Administration/AdminMain")); }
public ActionResult ChangeStudentGrade() { if ((Request.Form["gridRadios1"] != null) && (Request.Form["Student_id"] != null)) { string student_id = Request.Form["Student_id"]; int course_id = Convert.ToInt32(Request.Form["Course_id"]); int grade = Convert.ToInt32(Request.Form["Grade"]); string Lecturer = (string)Session["id"]; PDAL DBconnection = new PDAL(); UsersCourses Student = DBconnection.UsersCoursess.Find(student_id, course_id); string option = Request.Form["gridRadios1"].ToString(); string Course_Lecturer = "-1"; try { Course_Lecturer = (DBconnection.Courses.Find(course_id).lecturer_id).ToString(); } catch (Exception a) { if (a != null) { Course_Lecturer = "-1"; } } if (Regex.Replace(Course_Lecturer, " ", "") != Lecturer) { Session["Alert"] = "You dont have permission to change that course."; return(Redirect("~/Lecturers/LecturerMain")); } if (Student == null) { Session["Alert"] = "No such student."; return(Redirect("~/Lecturers/LecturerMain")); } if (option.Equals("option1")) { Student.moed1 = grade; Student.final = grade; } else if (option.Equals("option2")) { Student.moed2 = grade; Student.final = grade; } else { Student.final = grade; } DBconnection.SaveChanges(); } return(Redirect("~/Lecturers/LecturerMain")); }
public ActionResult ChangeCourseTime() { string day = Request.Form["day"]; TimeSpan start, end; try { start = TimeSpan.Parse(Request.Form["start"]); end = TimeSpan.Parse(Request.Form["end"]); if (start >= end) { Session["Alert"] = "Bad time format."; return(Redirect("~/Administration/AdminMain")); } } catch (Exception a) { a.GetType(); Session["Alert"] = "Bad time format."; return(Redirect("~/Administration/AdminMain")); } int Course_id = Convert.ToInt32(Request.Form["Course_id"]); PDAL DBconnection = new PDAL(); Course c = DBconnection.Courses.Find(Course_id); if (c == null) { Session["Alert"] = "No such course.";; return(Redirect("~/Administration/AdminMain")); } foreach (Course a in DBconnection.Courses) { if (a.day == c.day) { if (a != c) { if (CheckIfTimeOverlaps(a, start, end)) { Session["Alert"] = "Time overlaps other course."; return(Redirect("~/Administration/AdminMain")); } } } } c.end_time = end; c.start_time = start; DBconnection.SaveChanges(); return(Redirect("~/Administration/AdminMain")); }
public ActionResult AddStudentToCource() { int course_id; try { course_id = Convert.ToInt32(Request.Form["Course_id"]); }catch (Exception a) { a.GetType(); Session["Alert"] = "No such course."; return(Redirect("~/Administration/AdminMain")); } string Student_id = (string)Request.Form["Student_id"]; PDAL DBconnection = new PDAL(); UsersCourses Student = DBconnection.UsersCoursess.Find(Student_id, course_id); if (Student == null) { Session["Alert"] = "Student is alredy tacking the course or no such student."; return(Redirect("~/Administration/AdminMain")); } string role = (DBconnection.Users.Find(Student_id)).role.ToString(); if (Regex.Replace(role, " ", "") != "1") { Session["Alert"] = "The user is not student."; return(Redirect("~/Administration/AdminMain")); } if (CheckIfCourseOverlaps(Student_id, course_id)) { Session["Alert"] = "Course overlap with another course."; return(Redirect("~/Administration/AdminMain")); } Student = new UsersCourses(); Student.id = Student_id; Student.course = course_id; Student.moed1 = Student.moed2 = Student.final = 0; DBconnection.UsersCoursess.Add(Student); DBconnection.SaveChanges(); return(Redirect("~/Administration/AdminMain")); }