public ActionResult UpateRoleAuthor(string datalist, int rolid) { JavaScriptSerializer js = new JavaScriptSerializer(); List <AuthorUIModel> authorlist = js.Deserialize <List <AuthorUIModel> >(datalist);//获取要添加的权限 List <int> authorid = new List <int>(); foreach (var item in authorlist) { authorid.Add(item.AuthorIdUIModel); } JsonResultData <string> resultdata = new JsonResultData <string>(); ICollection <Author> authorlists = (ICollection <Author>)Session["authorlist"]; Author author = authorlists.FirstOrDefault(x => x.ControllerName == "Role" && x.ActionName == "UpateRoleAuthor"); if (author != null) { try { int result = roleservice.AddAuthorForRole(authorid, rolid); if (result == 0) { resultdata.Code = 0; resultdata.Data = "保存权限失败!"; } else if (result == -1) { 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)); }