Esempio n. 1
0
        public void DeclineGroupJoinRequest(long groupId, long userId)
        {
            GroupMember x = member_repo.GetFirstOrDefaultObject(m => m.GroupId == groupId && m.MemberId == userId && !m.IsAccepted);

            if (x == null)
            {
                throw new Exception("进组请求不存在!");
            }
            member_repo.Delete(x);
        }
Esempio n. 2
0
        /// <summary>
        /// 删除群组下的成员
        /// </summary>
        /// <param name="groupId"></param>
        public void DeleteMembersByGroupId(long groupId)
        {
            IEnumerable <GroupMember> groupMembers = groupMemberRepository.GetAllMembersOfGroup(groupId);

            foreach (var groupMember in groupMembers)
            {
                int affectCount = groupMemberRepository.Delete(groupMember);
                if (affectCount > 0)
                {
                    EventBus <GroupMember> .Instance().OnAfter(groupMember, new CommonEventArgs(EventOperationType.Instance().Delete()));

                    //用户的参与群组数-1
                    OwnerDataService ownerDataService = new OwnerDataService(TenantTypeIds.Instance().User());
                    ownerDataService.Change(groupMember.UserId, OwnerDataKeys.Instance().JoinedGroupCount(), -1);
                }
            }
        }