Exemplo n.º 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);
        }
Exemplo n.º 2
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));
        }
Exemplo n.º 3
0
        public override void Seed()
        {
            if (_channelRepository.Any() || !_userRepository.Any())
            {
                return;
            }

            var channels = new[]
            {
                new Channel()
                {
                    Id      = Guid.NewGuid(),
                    GroupId = new Guid("c49ff16c-842c-4c13-853c-acea6ee4d28d"),
                    Name    = "Offtopic"
                },
                new Channel()
                {
                    Id      = Guid.NewGuid(),
                    GroupId = new Guid("c49ff16c-842c-4c13-853c-acea6ee4d28d"),
                    Name    = "C# internals"
                },
                new Channel()
                {
                    Id      = Guid.NewGuid(),
                    GroupId = new Guid("c49ff16c-842c-4c13-853c-acea6ee4d28d"),
                    Name    = ".NET Core Framework"
                },
                new Channel()
                {
                    Id      = Guid.NewGuid(),
                    GroupId = new Guid("8f10e5e0-02f6-47cc-84c7-cd4e5b06792f"),
                    Name    = "3D modelling"
                },
                new Channel()
                {
                    Id      = Guid.NewGuid(),
                    GroupId = new Guid("8f10e5e0-02f6-47cc-84c7-cd4e5b06792f"),
                    Name    = "Unity jobs"
                },
                new Channel()
                {
                    Id      = Guid.NewGuid(),
                    GroupId = new Guid("8f10e5e0-02f6-47cc-84c7-cd4e5b06792f"),
                    Name    = "Tools"
                },
                new Channel()
                {
                    Id      = Guid.NewGuid(),
                    GroupId = new Guid("8f10e5e0-02f6-47cc-84c7-cd4e5b06792f"),
                    Name    = "Offtopic"
                },
                new Channel()
                {
                    Id      = Guid.NewGuid(),
                    GroupId = new Guid("3348dce8-26f0-4da5-b683-f0dedb462d62"),
                    Name    = "Frontend"
                },
                new Channel()
                {
                    Id      = Guid.NewGuid(),
                    GroupId = new Guid("3348dce8-26f0-4da5-b683-f0dedb462d62"),
                    Name    = "Backend"
                },
                new Channel()
                {
                    Id      = Guid.NewGuid(),
                    GroupId = new Guid("3348dce8-26f0-4da5-b683-f0dedb462d62"),
                    Name    = "DevOps / Serverless"
                }
            };

            var users = _userRepository.GetAll();

            foreach (var user in users)
            {
                foreach (var channel in channels)
                {
                    _channelUserRepository.Add(new ChannelUser(user, channel));
                }
            }

            var author = users.First();

            foreach (var channel in channels)
            {
                var group = _groupRepository.Get(channel.GroupId);
                _channelEventService.AddChannelCreatedEvent(group, author, channel);
            }
        }