public ActionResult DeleteConfirmed(int id) { StuSubTea stuSubTea = db.StuSubTeas.Find(id); db.StuSubTeas.Remove(stuSubTea); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "StuSubTeaID,StuSubID,TeachId,ReDate")] StuSubTea stuSubTea) { if (ModelState.IsValid) { db.Entry(stuSubTea).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.StuSubID = new SelectList(db.StudentSubjects, "StuSubID", "StuSubID", stuSubTea.StuSubID); ViewBag.TeachId = new SelectList(db.Teachers, "TeachId", "TeachName", stuSubTea.TeachId); return(View(stuSubTea)); }
// GET: StuSubTeas/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } StuSubTea stuSubTea = db.StuSubTeas.Find(id); if (stuSubTea == null) { return(HttpNotFound()); } return(View(stuSubTea)); }
// GET: StuSubTeas/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } StuSubTea stuSubTea = db.StuSubTeas.Find(id); if (stuSubTea == null) { return(HttpNotFound()); } ViewBag.StuSubID = new SelectList(db.StudentSubjects, "StuSubID", "StuSubID", stuSubTea.StuSubID); ViewBag.TeachId = new SelectList(db.Teachers, "TeachId", "TeachName", stuSubTea.TeachId); return(View(stuSubTea)); }
public ActionResult SaveCourse(int id) { var stu = User.Identity.GetUserId(); var Lev = db.TeacherClasses.Find(id).ClassID; var subj = db.TeacherClasses.Find(id).Teacher.SubID; var subjLevel = db.SubjectClasses.FirstOrDefault(x => x.LevelID == Lev && x.SubId == subj).SubLevelID; ViewBag.subjLevel = subjLevel; var Teacher = db.TeacherClasses.Find(id).TeachId; if (db.StudentSubjects.Any(x => x.SubLevelID == subjLevel && x.StuId == stu)) { var studentSubjectID = db.StudentSubjects.FirstOrDefault(x => x.SubLevelID == subjLevel && x.StuId == stu).StuSubID; StuSubTea subTea = new StuSubTea(); subTea.StuSubID = studentSubjectID; subTea.TeachId = Teacher; db.StuSubTeas.Add(subTea); db.SaveChanges(); } else { StudentSubject studentSubject = new StudentSubject(); studentSubject.SubLevelID = subjLevel; studentSubject.StuId = User.Identity.GetUserId(); db.StudentSubjects.Add(studentSubject); StuSubTea subTea = new StuSubTea(); subTea.StuSubID = studentSubject.StuSubID; subTea.TeachId = Teacher; db.StuSubTeas.Add(subTea); db.SaveChanges(); } return(View()); }