public ActionResult AddLecture(Lecturer lecture) { ICollection <Author> authorlist = (ICollection <Author>)Session["authorlist"]; Author author = authorlist.FirstOrDefault(x => x.ControllerName == "Lecturer" && x.ActionName == "AddLecture"); JsonResultData <string> resultdata = new JsonResultData <string>(); if (author != null) { try { int result = lectureservice.AddLecturer(lecture); if (result == 0) { resultdata.Code = 0; resultdata.Data = "添加失败"; } else { resultdata.Code = 1; resultdata.Data = "添加成功"; } } catch (Exception ex) { resultdata.Msg = ex.Message; } } else { resultdata.Code = 2; resultdata.Data = "没有权限"; } return(Json(resultdata, JsonRequestBehavior.AllowGet)); }