public ActionResult Index(StudentBatchProgramCourse studentBatchProgramCourse) { if (studentBatchProgramCourse.StudentID == null) { studentBatchProgramCourse.StudentID = 0; } ViewBag.BatchProgramID = new SelectList(db.GetBatchProgramNameConcat("", 0), "ID", "Name", studentBatchProgramCourse.BatchProgramID); ViewBag.YearSemesterNo = new SelectList(db.Semesters, "YearSemesterNo", "YearSemesterNo", studentBatchProgramCourse.YearSemesterNo); ViewBag.hdnBatchProgramID = studentBatchProgramCourse.BatchProgramID; ViewBag.hdnYearSemesterNo = studentBatchProgramCourse.YearSemesterNo; ViewBag.StudentID = studentBatchProgramCourse.StudentID; return(View("Index")); }
public ActionResult Unassign(int?id, int?sID) { int?BatchProgramID = 0; int?YearSemesterNo = 0; StudentBatchProgramCourse sbpc = new StudentBatchProgramCourse(); try { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } sbpc = db.StudentBatchProgramCourses.Find(id); if (sbpc == null) { return(HttpNotFound()); } else { BatchProgramID = sbpc.BatchProgramID; YearSemesterNo = sbpc.YearSemesterNo; db.StudentBatchProgramCourses.Remove(sbpc); db.SaveChanges(); ViewBag.MessageType = "success"; ViewBag.Message = "Record has been removed successfully."; } } catch (Exception ex) { ViewBag.MessageType = "error"; ViewBag.Message = ex.Message; } ViewBag.BatchProgramID = new SelectList(db.GetBatchProgramNameConcat("", 0), "ID", "Name"); ViewBag.YearSemesterNo = new SelectList(db.Semesters, "YearSemesterNo", "YearSemesterNo"); ViewBag.hdnBatchProgramID = BatchProgramID; ViewBag.hdnYearSemesterNo = YearSemesterNo; ViewBag.StudentID = sID; return(View("Index")); }