Beispiel #1
0
        public async Task Consume(ConsumeContext <GroupMembersUpdated> context)
        {
            try
            {
                var participants = await _groupAppService.GetUserIdsByIdAsync(context.Message.Id);

                await _manager.AddOrUpdateAsync(context.Message.Id, participants, ConversationType.CustomGroup);
            }
            catch (Exception ex)
            {
                _logger.Error(ex, ex.Message);
                throw;
            }
        }
        public async Task <RemotingResult> AddDepAsync(AddDepConversationInput input)
        {
            var userIds = await _employeeAppService.GetUserIdsByDepartmentIdAsync(input.DepartmentId);

            if (!userIds.Contains(input.UserId))
            {
                return(RemotingResult.Fail(1));
            }
            if (userIds.Count < 2)
            {
                return(RemotingResult.Fail(2));
            }

            await _manager.AddOrUpdateAsync(input.DepartmentId, userIds, ConversationType.DepartmentGroup);

            return(RemotingResult.Success());
        }
        public async Task AddOrUpdateAsync()
        {
            var target = new ConversationManager(stateManager);

            var id = Guid.NewGuid();

            await target.AddOrUpdateAsync(id, 
                new List<Guid> { Guid.NewGuid(), Guid.NewGuid(), }, 
                ConversationType.CustomGroup);

            //Assert:
            using (var tx = stateManager.CreateTransaction())
            {
                var dictIdToEntity = await Service.GetListDictAsync(stateManager);

                var idToEntity = await dictIdToEntity.TryGetValueAsync(tx, id);
                var conversation = idToEntity.Value;
                Assert.IsTrue(idToEntity.HasValue);
                Assert.IsTrue(conversation.Type == ConversationType.CustomGroup);
                Assert.IsTrue(conversation.Participants.Count == 2);
            }
        }