// GET: Course public ActionResult Index(int?id) { if (!this.User.IsInRole("Admin")) { return(RedirectToAction("Index", "Home")); } List <CourseModels> courses = db.coursemodels.ToList(); List <CourseModels> new_courses = new List <CourseModels>(); ViewBag.program_id = new SelectList(db.programModels, "program_Id", "programName"); if (id != null) { ProgramModels program = db.programModels.Find(id); ViewBag.program = program.programName; ViewBag.date = program.startDate + " - " + program.endDate; foreach (CourseModels course in courses) { if (course.program_Id == id) { course.programModels = program; new_courses.Add(course); } } ViewBag.prog_id = id; return(View(new_courses)); } else { return(RedirectToAction("Index", "ProgramModels")); } }
public ActionResult DeleteConfirmed(int id) { if (!this.User.IsInRole("Admin")) { return(RedirectToAction("Index", "Home")); } ProgramModels programModels = db.programModels.Find(id); db.programModels.Remove(programModels); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit(ProgramModels programModels) { if (!this.User.IsInRole("Admin")) { return(RedirectToAction("Index", "Home")); } if (ModelState.IsValid) { db.Entry(programModels).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(programModels)); }
public ActionResult Create(ProgramModels programModels) { if (!this.User.IsInRole("Admin")) { return(RedirectToAction("Index", "Home")); } if (ModelState.IsValid) { db.programModels.Add(programModels); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(programModels)); }
// GET: ProgramModels/Edit/5 public ActionResult Edit(int?id) { if (!this.User.IsInRole("Admin")) { return(RedirectToAction("Index", "Home")); } if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ProgramModels programModels = db.programModels.Find(id); if (programModels == null) { return(HttpNotFound()); } return(View(programModels)); }
public ActionResult Create(CourseModels course) { if (!this.User.IsInRole("Admin")) { return(RedirectToAction("Index", "Home")); } if (ModelState.IsValid) { int id = 0; id = course.program_Id; db.coursemodels.Add(course); db.SaveChanges(); return(RedirectToAction("Index/" + id)); } ProgramModels program = db.programModels.Find(course.program_Id); ViewBag.program = program.programName; ViewBag.date = program.startDate + " - " + program.endDate; return(View(course)); }
// GET: Course/Create public ActionResult Create(int?id) { if (!this.User.IsInRole("Admin")) { return(RedirectToAction("Index", "Home")); } if (id == null) { return(RedirectToAction("Index", "ProgramModels")); } ProgramModels program = db.programModels.Find(id); ViewBag.program = program.programName; ViewBag.date = program.startDate + " - " + program.endDate; CourseModels course = new CourseModels(); course.programModels = program; course.program_Id = program.program_Id; return(View(course)); }