public ActionResult AddTeacher(TeacherInfo teacherInfo) { teacherInfo.Authority = "1"; db.Set<TeacherInfo>().Add(teacherInfo); db.SaveChanges(); return RedirectToAction("AdminTeacherView", "AdminCourse"); }
public ActionResult GetPersonalInfo(TeacherInfo teacherInfo) { try { //获取用户(教师)cookie,cookie存储是ID string teacherId = TakeCookie.GetCookie("userId"); teacherInfo.Id =new Guid( teacherId); teacherInfo.Pwd = teacherInfo.Pwd.Trim(); if (string.IsNullOrEmpty(teacherInfo.Pwd) || teacherInfo.Pwd == "不修改就不需要输入") { modelHelp.Modify<TeacherInfo>(teacherInfo, new string[] { "Id", "Account", "UserName", "Sex" }); TempData["res"] = "修改成功"; return RedirectToAction("GetPersonalInfo"); } modelHelp.Modify<TeacherInfo>(teacherInfo, new string[] { "Id", "Account", "UserName", "Pwd", "Sex" }); TempData["res"] = "修改成功"; } catch (Exception) { TempData["res"] = "<font color='red'>修改失败,请点解cancel或刷新 后 重新输入!<font/>"; } return RedirectToAction("GetPersonalInfo"); }