public async Task <ActionResult> Edit([Bind(Include = "EnrollStudentID,CourseID,TeacherID,StudentID,SemesterID,Score,Remark")] AttendanceScoreModel attendanceScoreModel) { if (ModelState.IsValid) { db.Entry(attendanceScoreModel).State = EntityState.Modified; await db.SaveChangesAsync(); int RecordStored = UpdateAttendanceScore(attendanceScoreModel.EnrollStudentID, attendanceScoreModel.CourseID, attendanceScoreModel.TeacherID, attendanceScoreModel.Score); return(RedirectToAction("Index")); } ViewBag.CourseID = new SelectList(db.Courses, "CourseID", "CourseName", attendanceScoreModel.CourseID); ViewBag.SemesterID = new SelectList(db.Semesters, "SemesterID", "Session", attendanceScoreModel.SemesterID); ViewBag.StudentID = new SelectList(db.Students, "ProfileID", "StudentName", attendanceScoreModel.StudentID); ViewBag.TeacherID = new SelectList(db.Teachers, "ProfileID", "TeacherName", attendanceScoreModel.TeacherID); return(View(attendanceScoreModel)); }
public async Task <ActionResult> Edit(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } AttendanceScoreModel attendanceScoreModel = await db.AttendanceScores.FindAsync(id); if (attendanceScoreModel == null) { return(HttpNotFound()); } ViewBag.CourseID = new SelectList(db.Courses, "CourseID", "CourseName", attendanceScoreModel.CourseID); ViewBag.SemesterID = new SelectList(db.Semesters, "SemesterID", "Session", attendanceScoreModel.SemesterID); ViewBag.StudentID = new SelectList(db.Students, "ProfileID", "StudentName", attendanceScoreModel.StudentID); ViewBag.TeacherID = new SelectList(db.Teachers, "ProfileID", "TeacherName", attendanceScoreModel.TeacherID); return(View(attendanceScoreModel)); }