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()); } }
public ActionResult detail(int id) { UsersDAL dal = new UsersDAL(); JurisdictionDAL jdal = new JurisdictionDAL(); IList<JurisdictionModel> list = null; UsersModel users = null; try { users = dal.QuerySingle(" id=" + id); list = jdal.QuerySQL(" id!=5", " Sort"); } catch (Exception ex) { Log.Default.Error(ex); } if (users == null) users = new UsersModel(); ViewBag.users = users; if (list == null) list = new List<JurisdictionModel>(); ViewBag.list = list; return View(); }