public ActionResult CheckCreate(CourseTb temp) { if (Session["myinfo"] == null) { ViewBag.lol = "You have to login First"; return(RedirectToAction("Login", "Home", new { msg = ViewBag.lol })); } if (temp.ID == null) { TempData["errormsg"] = "You must enter ID"; return(View("CheckOne")); } foreach (CourseTb stam in mod.CourseTb) { if (stam.ID == temp.ID) { TempData["errormsg"] = "ID Exist"; return(View("CheckOne")); } } if (temp.Name == null) { TempData["errormsg"] = "You must enter Name"; } else if (temp.Points == null) { TempData["errormsg"] = "You must enter Points"; } else if (temp.Time == null) { TempData["errormsg"] = "You must enter Time"; } else if (temp.ExamA.Equals(null)) { TempData["errormsg"] = "You must enter ExamA"; } else if (temp.ExamB.Equals(null)) { TempData["errormsg"] = "You must enter ExamB"; } else if (temp.Day == null) { TempData["errormsg"] = "You must enter Day"; } else if (temp.Class == null) { TempData["errormsg"] = "You must enter Class"; } else { mod.CourseTb.Add(temp); mod.SaveChanges(); TempData["confirmMsg"] = "Updated "; } return(View("CheckOne")); }
public ActionResult Edit(CourseTb couID) { if (Session["myinfo"] == null) { ViewBag.lol = "You have to login First"; return(RedirectToAction("Login", "Home", new { msg = ViewBag.lol })); } Session["User"] = couID.ID; return(View()); }
public ActionResult CheckOne(User aa) { if (Session["myinfo"] == null) { ViewBag.lol = "You have to login First"; return(RedirectToAction("Login", "Home", new { msg = ViewBag.lol })); } bool ch = false; foreach (User temp in mod.User) { if (aa.ID == temp.ID && temp.Type.Equals(1)) { ch = true; } } if (!ch) { TempData["temp1"] = " Student not found"; return(View("One")); } ch = false; foreach (CourseTb temp in mod.CourseTb) { if (aa.Lname == temp.ID) { ch = true; } } if (!ch) { TempData["temp1"] = " Course not found"; return(View("One")); } foreach (GradesTb temp in mod.GradesTb) { if (aa.ID.ToString() == temp.StudentID && aa.Lname == temp.CourseID) { TempData["temp1"] = "The student already in course"; return(View("One")); } } foreach (GradesTb temp in mod.GradesTb) { if (aa.ID.ToString() == temp.StudentID && aa.Lname == temp.CourseID) { TempData["temp1"] = "The student already in course"; return(View("One")); } } CourseTb temp1 = new CourseTb(); foreach (CourseTb temp in mod.CourseTb) { if (aa.Lname == temp.ID) { temp1 = temp; } } foreach (CourseTb temp in mod.CourseTb) { if (temp1.Day == temp.Day && temp1.Time == temp.Time && temp1.ID != temp.ID) { TempData["temp1"] = "The course time is busy"; return(View("One")); } } GradesTb newSt = new GradesTb(); newSt.CourseID = aa.Lname; newSt.StudentID = aa.ID.ToString(); newSt.GradeB = null; newSt.GradeA = null; mod.GradesTb.Add(newSt); mod.SaveChanges(); TempData["temp1"] = "Done!"; return(View("One")); }
public ActionResult CheckEdit(CourseTb temp) { if (Session["myinfo"] == null) { ViewBag.lol = "You have to login First"; return(RedirectToAction("Login", "Home", new { msg = ViewBag.lol })); } var stam = Session["User"]; CourseTb cou = new CourseTb(), course = new CourseTb(); foreach (CourseTb sd in mod.CourseTb) { if (stam.Equals(sd.ID)) { course = sd; cou = sd; } } if (temp.Name != null) { cou.Name = temp.Name; } if (temp.Points != null) { cou.Points = temp.Points; } if (!temp.ExamA.Equals(null)) { cou.ExamA = temp.ExamA; } if (!temp.ExamB.Equals(null)) { cou.ExamB = temp.ExamB; } if (temp.Lecturer != null) { cou.Lecturer = temp.Lecturer; } if (temp.Time != null) { cou.Time = temp.Time; } if (temp.Day != null) { cou.Day = temp.Day; } if (temp.Class != null) { cou.Class = temp.Class; } if (!course.Equals(cou)) { mod.CourseTb.Remove(cou); mod.CourseTb.Add(cou); mod.SaveChanges(); } return(View("Edit")); }