public ActionResult DeleteConfirmed(int id) { StaffSubjects staffSubjects = db.StaffSubjects.Find(id); db.StaffSubjects.Remove(staffSubjects); db.SaveChanges(); return(RedirectToAction("Index")); }
// GET: StaffSubjects/Create public ActionResult Create() { ViewBag.SubjectId = new SelectList(db.GradeSubjects, "GradeSubjectId", "GradeName"); ViewBag.StaffId = new SelectList(db.Staffs, "StaffId", "Title"); ViewBag.SubjectId = new SelectList(db.Subjects, "SubjectId", "SubjectName"); var staffSubjects = new StaffSubjects(); Dictionary <int, string> teacherCollection = GetTeacherNameComboCollection(); staffSubjects.TeacherNameCollection = teacherCollection.Values.ToList(); return(View(staffSubjects)); }
public ActionResult Edit([Bind(Include = "StaffSubjectId,GradeSubjectId,GradeName,SubjectId,SubjectName,StaffId,AssignedTeacher")] StaffSubjects staffSubjects) { Dictionary <int, string> teacherCollection = GetTeacherNameComboCollection(); db.Entry(staffSubjects).State = EntityState.Modified; db.SaveChanges(); ViewBag.SubjectId = new SelectList(db.GradeSubjects, "GradeSubjectId", "GradeName", staffSubjects.SubjectId); ViewBag.StaffId = new SelectList(db.Staffs, "StaffId", "Title", staffSubjects.StaffId); ViewBag.SubjectId = new SelectList(db.Subjects, "SubjectId", "SubjectName", staffSubjects.SubjectId); return(RedirectToAction("Index")); }
// GET: StaffSubjects/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } StaffSubjects staffSubjects = db.StaffSubjects.Find(id); if (staffSubjects == null) { return(HttpNotFound()); } return(View(staffSubjects)); }
public ActionResult Create([Bind(Include = "StaffSubjectId,GradeSubjectId,GradeName,SubjectId,SubjectName,StaffId,AssignedTeacher")] StaffSubjects staffSubjects) { Dictionary <int, string> teacherCollection = GetTeacherNameComboCollection(); staffSubjects.TeacherNameCollection = teacherCollection.Values.ToList(); if (ModelState.IsValid) { db.StaffSubjects.Add(staffSubjects); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.SubjectId = new SelectList(db.GradeSubjects, "GradeSubjectId", "GradeName", staffSubjects.SubjectId); ViewBag.StaffId = new SelectList(db.Staffs, "StaffId", "Title", staffSubjects.StaffId); ViewBag.SubjectId = new SelectList(db.Subjects, "SubjectId", "SubjectName", staffSubjects.SubjectId); return(View(staffSubjects)); }
// GET: StaffSubjects/Edit/5 public ActionResult Edit(int?id) { Dictionary <int, string> teacherCollection = GetTeacherNameComboCollection(); if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } StaffSubjects staffSubjects = db.StaffSubjects.Find(id); if (staffSubjects == null) { return(HttpNotFound()); } staffSubjects.TeacherNameCollection = teacherCollection.Values.ToList(); ViewBag.SubjectId = new SelectList(db.GradeSubjects, "GradeSubjectId", "GradeName", staffSubjects.SubjectId); ViewBag.StaffId = new SelectList(db.Staffs, "StaffId", "Title", staffSubjects.StaffId); ViewBag.SubjectId = new SelectList(db.Subjects, "SubjectId", "SubjectName", staffSubjects.SubjectId); return(View(staffSubjects)); }