/// <summary> /// 加入某个组。 /// </summary> public JoinGroupResult JoinGroup(string userID, string groupID) { GGGroup group = this.groupCache.Get(groupID); if (group == null) { return(JoinGroupResult.GroupNotExist); } GGUser user = this.userCache.Get(userID); if (!user.GroupList.Contains(groupID)) { user.JoinGroup(groupID); this.dbPersister.ChangeUserGroups(user.UserID, user.Groups); } if (!group.MemberList.Contains(userID)) { group.AddMember(userID); this.dbPersister.UpdateGroup(group); } return(JoinGroupResult.Succeed); }
/// <summary> /// 创建组 /// </summary> public CreateGroupResult CreateGroup(string creatorID, string groupID, string groupName, string announce, string admin, string noSpeak) { if (this.groupCache.Contains(groupID)) { return(CreateGroupResult.GroupExisted); } GGGroup group = new GGGroup(groupID, groupName, creatorID, announce, creatorID, admin, noSpeak); this.groupCache.Add(groupID, group); this.dbPersister.InsertGroup(group); GGUser user = this.userCache.Get(creatorID); user.JoinGroup(groupID); this.dbPersister.ChangeUserGroups(user.UserID, user.Groups); return(CreateGroupResult.Succeed); }