示例#1
0
        public APIReturn Post_insert([FromForm] string Name, [FromForm] ulong[] mn_Users)
        {
            RolesInfo item = new RolesInfo();

            item.Name = Name;
            item      = Roles.Insert(item);
            //关联 Users
            foreach (ulong mn_Users_in in mn_Users)
            {
                item.FlagUsers(mn_Users_in);
            }
            return(new APIReturn(0, "成功", "item", item.ToBson()));
        }
示例#2
0
        public APIReturn Put_update(uint?Id, [FromForm] string Name, [FromForm] ulong[] mn_Users)
        {
            RolesInfo item = new RolesInfo();

            item.Id   = Id;
            item.Name = Name;
            int affrows = Roles.Update(item);

            //关联 Users
            if (mn_Users.Length == 0)
            {
                item.UnflagUsersALL();
            }
            else
            {
                List <ulong> mn_Users_list = mn_Users.ToList();
                foreach (UsersInfo Obj_users in item.Obj_userss)
                {
                    int idx = mn_Users_list.FindIndex(a => a == Obj_users.Id);
                    if (idx == -1)
                    {
                        item.UnflagUsers(Obj_users.Id);
                    }
                    else
                    {
                        mn_Users_list.RemoveAt(idx);
                    }
                }
                mn_Users_list.ForEach(a => item.FlagUsers(a));
            }
            if (affrows > 0)
            {
                return(new APIReturn(0, "成功"));
            }
            return(new APIReturn(99, "失败"));
        }