public ActionResult savejurisdiction(int userid, bool isenable, int tid) { UsersDAL dal = new UsersDAL(); JurisdictionDAL jdal = new JurisdictionDAL(); try { UsersModel users = dal.QuerySingle(" id=" + userid); if (users == null) return Content(false.ToResult("用户错误").ToJsonString()); JurisdictionModel model = jdal.QuerySingle(" id=" + tid); if (model == null) return Content(false.ToResult("权限项错误").ToJsonString()); List<string> liststrs = users.Jurisdiction.Split(',').ToList(); if (liststrs.Any(c => c == tid.ToString())) liststrs.Remove(tid.ToString()); if (isenable) { liststrs.Add(tid.ToString()); } liststrs.Remove(""); users.Jurisdiction = string.Join(",", liststrs.ToArray()); dal.UpdateSQL(users); return Content(true.ToResult().ToJsonString()); } catch (Exception ex) { Log.Default.Error(ex); return Content(false.ToResult("网络错误,请稍后重试").ToJsonString()); } }