public ActionResult Delete(AppUser appUser) { UpdateModel(appUser); AspNetRole role = roleService.GetRoleOfUser(appUser.Id); if (role != null) { if (role.Id == (int)Config.Roles.Student) { studentService.DeleteByUserID(appUser.Id); } else if (role.Id == (int)Config.Roles.Teacher) { teacherService.DeleteByUserID(appUser.Id); } roleService.DeleteAllRoleOfUser(appUser.Id); accountService.DeleteByPrimaryKey(appUser.Id); return(RedirectToAction("Index")); } return(View(appUser)); }