private MethodPacket BuildDeleteGroupPacket(InteractiveGroupModel groupToDelete, InteractiveGroupModel groupToReplace) { Validator.ValidateVariable(groupToDelete, "groupToDelete"); Validator.ValidateVariable(groupToReplace, "groupToReplace"); JObject parameters = new JObject(); parameters.Add("groupID", groupToDelete.groupID); parameters.Add("reassignGroupID", groupToReplace.groupID); return(new MethodParamsPacket("deleteGroup", parameters)); }
public void CreateGetUpdateDeleteGroup() { this.InteractiveWrapper(async(MixerConnection connection, InteractiveClient interactiveClient) => { InteractiveConnectedSceneModel testScene = await this.CreateScene(interactiveClient); this.ClearPackets(); InteractiveGroupModel testGroup = new InteractiveGroupModel() { groupID = GroupID, sceneID = testScene.sceneID }; bool result = await interactiveClient.CreateGroupsWithResponse(new List <InteractiveGroupModel>() { testGroup }); Assert.IsTrue(result); this.ClearPackets(); InteractiveGroupCollectionModel groups = await interactiveClient.GetGroups(); Assert.IsNotNull(groups); Assert.IsNotNull(groups.groups); Assert.IsTrue(groups.groups.Count > 0); testGroup = groups.groups.FirstOrDefault(g => g.groupID.Equals(GroupID)); InteractiveGroupModel defaultGroup = groups.groups.FirstOrDefault(g => g.groupID.Equals("default")); this.ClearPackets(); groups = await interactiveClient.UpdateGroupsWithResponse(new List <InteractiveGroupModel>() { testGroup }); Assert.IsNotNull(groups); Assert.IsNotNull(groups.groups); Assert.IsTrue(groups.groups.Count > 0); testGroup = groups.groups.FirstOrDefault(g => g.groupID.Equals(GroupID)); this.ClearPackets(); result = await interactiveClient.DeleteGroupWithResponse(testGroup, defaultGroup); Assert.IsTrue(result); await this.DeleteScene(interactiveClient, testScene); }); }
protected override async Task PerformInternal(UserViewModel user, IEnumerable <string> arguments) { if (ChannelSession.Interactive != null && ChannelSession.Interactive.Client.Authenticated) { if (!user.Roles.Any(r => r >= this.RoleRequirement)) { if (ChannelSession.Chat != null) { await ChannelSession.Chat.Whisper(user.UserName, "You do not permission to perform this action."); } return; } if (this.group == null) { InteractiveGroupCollectionModel groups = await ChannelSession.Interactive.GetGroups(); if (groups != null && groups.groups != null) { this.group = groups.groups.FirstOrDefault(g => g.groupID.Equals(this.GroupName)); if (this.group == null) { this.group = new InteractiveGroupModel() { groupID = this.GroupName, sceneID = this.SceneID }; await ChannelSession.Interactive.CreateGroups(new List <InteractiveGroupModel>() { this.group }); } } } if (this.InteractiveType == InteractiveActionTypeEnum.MoveGroupToScene || this.InteractiveType == InteractiveActionTypeEnum.MoveUserToScene) { this.group.sceneID = this.SceneID; await ChannelSession.Interactive.UpdateGroups(new List <InteractiveGroupModel>() { this.group }); } if (this.InteractiveType == InteractiveActionTypeEnum.MoveUserToGroup || this.InteractiveType == InteractiveActionTypeEnum.MoveUserToScene) { InteractiveParticipantModel participant = ChannelSession.Interactive.InteractiveUsers.Values.FirstOrDefault(p => p.userID.Equals(user.ID)); if (participant != null) { participant.groupID = this.GroupName; await ChannelSession.Interactive.UpdateParticipants(new List <InteractiveParticipantModel>() { participant }); } } } }
public async Task UpdateGroup(string groupName, string sceneID) { InteractiveGroupCollectionModel groups = await ChannelSession.Interactive.GetGroups(); if (groups != null && groups.groups != null) { InteractiveGroupModel group = groups.groups.FirstOrDefault(g => g.groupID.Equals(groupName)); if (group != null) { group.sceneID = sceneID; await this.RunAsync(this.Client.UpdateGroups(new List <InteractiveGroupModel>() { group })); } } }
/// <summary> /// Deletes and replaces the specified group /// </summary> /// <param name="groupToDelete">The group to delete</param> /// <param name="groupToReplace">The group to replace with</param> /// <returns>Whether the operation succeeded</returns> public async Task <bool> DeleteGroupWithResponse(InteractiveGroupModel groupToDelete, InteractiveGroupModel groupToReplace) { return(this.VerifyNoErrors(await this.SendAndListen(this.BuildDeleteGroupPacket(groupToDelete, groupToReplace)))); }
/// <summary> /// Deletes and replaces the specified group /// </summary> /// <param name="groupToDelete">The group to delete</param> /// <param name="groupToReplace">The group to replace with</param> /// <returns>The task object representing the asynchronous operation</returns> public async Task DeleteGroup(InteractiveGroupModel groupToDelete, InteractiveGroupModel groupToReplace) { await this.Send(this.BuildDeleteGroupPacket(groupToDelete, groupToReplace)); }
public InteractiveUserGroupViewModel(InteractiveGroupModel group) : this(group.groupID, group.sceneID) { }
public async Task DeleteGroup(InteractiveGroupModel groupToDelete, InteractiveGroupModel groupToReplace) { await this.RunAsync(this.Client.DeleteGroup(groupToDelete, groupToReplace)); }