public ActionResult DeleteTeacher(string id) { _TeacherListPartialModel vm = new _TeacherListPartialModel(); 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 teacher = userManager.FindById(id); if (teacher == null) { return(HttpNotFound()); } vm = new _TeacherListPartialModel { FirstName = teacher.FirstName, LastName = teacher.LastName, EMail = teacher.Email, Id = teacher.Id }; } return(PartialView(vm)); }
public ActionResult DeleteTeacher(_TeacherListPartialModel teacher) { if (teacher == null) { return(RedirectToAction("_TeacherListPartial")); } var dbteacher = context.Users.Find(teacher.Id); if (dbteacher == null) { RedirectToAction("_TeacherListPartial"); } context.Entry(dbteacher).State = EntityState.Deleted; context.SaveChanges(); return(RedirectToAction("_TeacherListPartial")); }