public void JoinMember(Gang gang, Character member, bool joinChannel) { _gangRepository.InsertMember(gang, member); void Finish() { gang.SetMember(member); var data = new Dictionary <string, object> { { k.data, gang.GetGangData() }, { k.memberID, member.Id } }; Message.Builder.SetCommand(Commands.GangAddMember).WithData(data).ToCharacters(gang.GetMembers()).Send(); GangMemberJoined?.Invoke(gang, member); if (joinChannel) { _channelManager.JoinChannel(gang.ChannelName, member); } } if (Transaction.Current != null) { Transaction.Current.OnCommited(Finish); } else { Finish(); } }
public void SetRole(Gang gang, Character member, GangRole newRole) { if (gang.Leader == member) { return; } if (!gang.IsMember(member)) { throw new PerpetuumException(ErrorCodes.CharacterNotInTheCurrentGang); } _gangRepository.UpdateMemberRole(gang, member, newRole); void Finish() { gang.SetMember(member, newRole); Message.Builder.SetCommand(Commands.GangSetRole).WithData(new Dictionary <string, object> { { k.memberID, member.Id }, { k.role, (int)newRole } }).ToCharacters(gang.GetMembers()).Send(); var channelMemberRole = gang.HasRole(member, GangRole.Assistant) ? ChannelMemberRole.Operator : ChannelMemberRole.Undefined; _channelManager.SetMemberRole(gang.ChannelName, member, channelMemberRole); } if (Transaction.Current == null) { Transaction.Current.OnCommited(Finish); } else { Finish(); } }