public ActionResult DeleteStudentFullList(string id) { _StudentListPartial vm = new _StudentListPartial(); if (id != null) { UserStore <Models.Identity.ApplicationUser> userStore = new UserStore <Models.Identity.ApplicationUser>(context); UserManager <Models.Identity.ApplicationUser> userManager = new UserManager <Models.Identity.ApplicationUser>(userStore); var student = userManager.FindById(id); if (student == null) { return(HttpNotFound()); } vm = new _StudentListPartial { FirstName = student.FirstName, LastName = student.LastName, EMail = student.Email, CourseId = student.CourseId, Id = student.Id }; } return(PartialView("_DeleteStudentPartialFullList", vm)); }
public ActionResult DeleteStudentFullList(_StudentListPartial student) { if (student == null) { return(RedirectToAction("_FullStudentListPartial")); // Will generate yellow screen of death probably } var dbstudent = context.Users.Find(student.Id); int cid = dbstudent.CourseId.Id; if (dbstudent == null) { RedirectToAction("_FullStudentListPartial", new { id = cid }); } context.Entry(dbstudent).State = EntityState.Deleted; context.SaveChanges(); return(RedirectToAction("_FullStudentListPartial", new { id = cid })); }