示例#1
0
        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 <DsdRole, Guid> >().GetByKey(id);
                    if (entity != null)
                    {
                        if (!isAssigned)
                        {
                            AcDomain.Handle(new RemoveDsdRoleCommand(AcSession, id));
                        }
                    }
                    else if (isAssigned)
                    {
                        var createInput = new DsdRoleCreateIo
                        {
                            Id       = new Guid(row["Id"].ToString()),
                            RoleId   = new Guid(row["RoleId"].ToString()),
                            DsdSetId = new Guid(row["DsdSetId"].ToString())
                        };
                        AcDomain.Handle(createInput.ToCommand(AcSession));
                    }
                }
            }

            return(this.JsonResult(new ResponseData {
                success = true
            }));
        }
示例#2
0
        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<DsdRole>>().GetByKey(id);
                    if (entity != null)
                    {
                        if (!isAssigned)
                        {
                            AcDomain.Handle(new RemoveDsdRoleCommand(AcSession, id));
                        }
                    }
                    else if (isAssigned)
                    {
                        var createInput = new DsdRoleCreateIo
                        {
                            Id = new Guid(row["Id"].ToString()),
                            RoleId = new Guid(row["RoleId"].ToString()),
                            DsdSetId = new Guid(row["DsdSetId"].ToString())
                        };
                        AcDomain.Handle(createInput.ToCommand(AcSession));
                    }
                }
            }

            return this.JsonResult(new ResponseData { success = true });
        }