public ActionResult AddOrDeleteRoleMembers() { String json = Request["data"]; var rows = (ArrayList)MiniJSON.Decode(json); foreach (Hashtable row in rows) { var id = new Guid(row["Id"].ToString()); //根据记录状态,进行不同的增加、删除、修改操作 String state = row["_state"] != null ? row["_state"].ToString() : ""; //更新:_state为空或modified if (state == "modified" || state == "") { bool isAssigned = bool.Parse(row["IsAssigned"].ToString()); var entity = GetRequiredService <IRepository <SsdRole, Guid> >().GetByKey(id); if (entity != null) { if (!isAssigned) { AcDomain.Handle(new RemoveSsdRoleCommand(AcSession, id)); } } else if (isAssigned) { var createInput = new SsdRoleCreateIo { Id = new Guid(row["Id"].ToString()), RoleId = new Guid(row["RoleId"].ToString()), SsdSetId = new Guid(row["SsdSetId"].ToString()) }; AcDomain.Handle(createInput.ToCommand(AcSession)); } } } return(this.JsonResult(new ResponseData { success = true })); }
public ActionResult AddOrDeleteRoleMembers() { String json = Request["data"]; var rows = (ArrayList)MiniJSON.Decode(json); foreach (Hashtable row in rows) { var id = new Guid(row["Id"].ToString()); //根据记录状态,进行不同的增加、删除、修改操作 String state = row["_state"] != null ? row["_state"].ToString() : ""; //更新:_state为空或modified if (state == "modified" || state == "") { bool isAssigned = bool.Parse(row["IsAssigned"].ToString()); var entity = GetRequiredService<IRepository<SsdRole>>().GetByKey(id); if (entity != null) { if (!isAssigned) { AcDomain.Handle(new RemoveSsdRoleCommand(AcSession, id)); } } else if (isAssigned) { var createInput = new SsdRoleCreateIo { Id = new Guid(row["Id"].ToString()), RoleId = new Guid(row["RoleId"].ToString()), SsdSetId = new Guid(row["SsdSetId"].ToString()) }; AcDomain.Handle(createInput.ToCommand(AcSession)); } } } return this.JsonResult(new ResponseData { success = true }); }