Пример #1
0
        private void AddUserToChannel(Models.User user, Guid channelId)
        {
            var channel = _channelRepository.Get(channelId);

            var channelUser = new ChannelUser(user, channel);

            _channelUserRepository.Add(channelUser);

            var channelUserDocument = new Documents.ChannelUser(user.Id, channelId);

            _channelUserStore.AddToBus(channelUserDocument);

            _channelEventService.AddUserAddedToChannelEvent(channel.Group, _authorizedUser, user, channel);
        }
Пример #2
0
        public override void Seed()
        {
            if (_channelUserStore.Any() || !_channelUserRepository.Any())
            {
                return;
            }

            var channelUsers = _channelUserRepository.GetAll();
            var author       = channelUsers.First().User;

            foreach (var channelUser in channelUsers)
            {
                _channelUserStore.Add(new ChannelUser(channelUser.UserId, channelUser.ChannelId));

                var group = _groupRepository.Get(channelUser.Channel.GroupId);
                _channelEventService.AddUserAddedToChannelEvent(group, author, channelUser.User, channelUser.Channel);
            }
        }
Пример #3
0
        public ChannelResponse Create(Guid groupId, string name)
        {
            var channel = new Models.Channel
            {
                Id      = Guid.NewGuid(),
                GroupId = groupId,
                Name    = name
            };

            var channelUser = new ChannelUser(_authorizedUser, channel);

            _channelUserRepository.Add(channelUser);

            var channelUserDocument = new Documents.ChannelUser(_authorizedUser.Id, channel.Id);

            _channelUserStore.AddToBus(channelUserDocument);

            var group = _groupRepository.Get(groupId);

            _channelEventService.AddChannelCreatedEvent(group, _authorizedUser, channel);
            _channelEventService.AddUserAddedToChannelEvent(group, _authorizedUser, _authorizedUser, channel);

            return(_mapper.Map <ChannelResponse>(channel));
        }