コード例 #1
0
ファイル: CreateCommand.cs プロジェクト: liannoi/wlodzimierz
            private async Task CreateAsync(Contact entity, CancellationToken cancellationToken)
            {
                await _context.Contacts.AddAsync(entity, cancellationToken);

                Notify(entity);
                await _context.SaveChangesAsync(cancellationToken);
            }
コード例 #2
0
            public async Task <Unit> Handle(UpdateCommand request, CancellationToken cancellationToken)
            {
                var entity = await _context.Groups.FindAsync(request.GroupId) ??
                             throw new NotFoundException(nameof(Group), request.GroupId);

                entity.Name = request.Name;
                await _context.SaveChangesAsync(cancellationToken);

                return(Unit.Value);
            }
コード例 #3
0
            public async Task <Unit> Handle(DeleteCommand request, CancellationToken cancellationToken)
            {
                var entity = await _context.Conversations.FindAsync(request.ConversationId) ??
                             throw new NotFoundException(nameof(Conversation), request.ConversationId);

                _context.Conversations.Remove(entity);
                await _context.SaveChangesAsync(cancellationToken);

                return(Unit.Value);
            }
コード例 #4
0
ファイル: DeleteCommand.cs プロジェクト: liannoi/wlodzimierz
            public async Task <Unit> Handle(DeleteCommand command, CancellationToken cancellationToken)
            {
                var entity = await _context.UserBlacklists.FindAsync(command.UserBlacklistId) ??
                             throw new NotFoundException(nameof(UserBlacklist), command.UserBlacklistId);

                _context.UserBlacklists.Remove(entity);
                await _context.SaveChangesAsync(cancellationToken);

                return(Unit.Value);
            }
コード例 #5
0
            public async Task <Unit> Handle(DeleteCommand command, CancellationToken cancellationToken)
            {
                var entity = await _context.GroupAdministrators.FindAsync(command.GroupAdministratorId) ??
                             throw new NotFoundException(nameof(GroupAdministrator), command.GroupAdministratorId);

                _context.GroupAdministrators.Remove(entity);
                await _context.SaveChangesAsync(cancellationToken);

                return(Unit.Value);
            }
コード例 #6
0
ファイル: UpdateCommand.cs プロジェクト: JACKHANI/wlodzimierz
            public async Task <Unit> Handle(UpdateCommand request, CancellationToken cancellationToken)
            {
                var entity = await _context.Conversations.FindAsync(request.ConversationId) ??
                             throw new NotFoundException(nameof(Conversation), request.ConversationId);

                entity.LeftUserId  = request.LeftUserId;
                entity.RightUserId = request.RightUserId;
                await _context.SaveChangesAsync(cancellationToken);

                return(Unit.Value);
            }
コード例 #7
0
            public async Task <Unit> Handle(UpdateCommand command, CancellationToken cancellationToken)
            {
                var entity = await _context.GroupAdministrators.FindAsync(command.GroupAdministratorId) ??
                             throw new NotFoundException(nameof(GroupAdministrator), command.GroupAdministratorId);

                entity.GroupId             = command.Group.GroupId;
                entity.AdministratorUserId = command.AdministratorUserId;
                await _context.SaveChangesAsync(cancellationToken);

                return(Unit.Value);
            }
コード例 #8
0
ファイル: CreateCommand.cs プロジェクト: liannoi/wlodzimierz
            public async Task <int> Handle(CreateCommand command, CancellationToken cancellationToken)
            {
                var entity = new Group {
                    Name = command.Name
                };
                await _context.Groups.AddAsync(entity, cancellationToken);

                await _context.SaveChangesAsync(cancellationToken);

                return(entity.GroupId);
            }
コード例 #9
0
            public async Task <Unit> Handle(UpdateCommand request, CancellationToken cancellationToken)
            {
                var entity = await _context.UserBlacklists.FindAsync(request.UserBlacklistId) ??
                             throw new NotFoundException(nameof(UserBlacklist), request.UserBlacklistId);

                entity.OwnerUserId   = request.OwnerUserId;
                entity.BlockedUserId = request.BlockedUserId;
                await _context.SaveChangesAsync(cancellationToken);

                return(Unit.Value);
            }
コード例 #10
0
ファイル: UpdateCommand.cs プロジェクト: JACKHANI/wlodzimierz
            public async Task <Unit> Handle(UpdateCommand request, CancellationToken cancellationToken)
            {
                var entity = await _context.ConversationMessages.FindAsync(request.ConversationMessageId) ??
                             throw new NotFoundException(nameof(ConversationMessage), request.ConversationMessageId);

                entity.ConversationId = request.Conversation.ConversationId;
                entity.OwnerUserId    = request.OwnerUserId;
                entity.Message        = request.Message;
                entity.Publish        = request.Publish;
                await _context.SaveChangesAsync(cancellationToken);

                return(Unit.Value);
            }
コード例 #11
0
            public async Task <int> Handle(CreateCommand request, CancellationToken cancellationToken)
            {
                var entity = new UserBlacklist
                {
                    OwnerUserId = request.OwnerUserId, BlockedUserId = request.BlockedUserId
                };

                await _context.UserBlacklists.AddAsync(entity, cancellationToken);

                await _context.SaveChangesAsync(cancellationToken);

                return(entity.UserBlacklistId);
            }
コード例 #12
0
            public async Task <Unit> Handle(UpdateCommand command, CancellationToken cancellationToken)
            {
                var entity = await _context.GroupMessages.FindAsync(command.GroupMessageId) ??
                             throw new NotFoundException(nameof(GroupMessage), command.GroupMessageId);

                entity.GroupId     = command.Group.GroupId;
                entity.OwnerUserId = command.OwnerUserId;
                entity.Message     = command.Message;
                entity.Publish     = command.Publish;
                await _context.SaveChangesAsync(cancellationToken);

                return(Unit.Value);
            }
コード例 #13
0
            public async Task <int> Handle(CreateCommand request, CancellationToken cancellationToken)
            {
                var entity = new Conversation
                {
                    LeftUserId  = request.LeftUserId,
                    RightUserId = request.RightUserId
                };

                await _context.Conversations.AddAsync(entity, cancellationToken);

                await _context.SaveChangesAsync(cancellationToken);

                return(entity.ConversationId);
            }
コード例 #14
0
ファイル: CreateCommand.cs プロジェクト: liannoi/wlodzimierz
            public async Task <int> Handle(CreateCommand command, CancellationToken cancellationToken)
            {
                var entity = new GroupAdministrator
                {
                    GroupId             = command.Group.GroupId,
                    AdministratorUserId = command.AdministratorUserId
                };

                await _context.GroupAdministrators.AddAsync(entity, cancellationToken);

                await _context.SaveChangesAsync(cancellationToken);

                return(entity.GroupAdministratorId);
            }
コード例 #15
0
            public async Task <Unit> Handle(UpdateCommand request, CancellationToken cancellationToken)
            {
                var entity = await _context.Contacts.FindAsync(request.ContactId) ??
                             throw new NotFoundException(nameof(Contact), request.ContactId);

                entity.FirstName   = request.FirstName;
                entity.LastName    = request.LastName;
                entity.Email       = request.Email;
                entity.Photo       = request.Photo;
                entity.OwnerUserId = request.OwnerUser.UserId;
                await _context.SaveChangesAsync(cancellationToken);

                return(Unit.Value);
            }
コード例 #16
0
ファイル: CreateCommand.cs プロジェクト: liannoi/wlodzimierz
            public async Task <int> Handle(CreateCommand command, CancellationToken cancellationToken)
            {
                var entity = new GroupBlacklist
                {
                    GroupId       = command.Group.GroupId,
                    BlockedUserId = command.BlockedUserId
                };

                await _context.GroupBlacklists.AddAsync(entity, cancellationToken);

                await _context.SaveChangesAsync(cancellationToken);

                return(entity.GroupBlacklistId);
            }
コード例 #17
0
            public async Task <int> Handle(CreateCommand command, CancellationToken cancellationToken)
            {
                var entity = new GroupMessage
                {
                    GroupId     = command.Group.GroupId,
                    OwnerUserId = command.OwnerUserId,
                    Message     = command.Message,
                    Publish     = command.Publish
                };

                await _context.GroupMessages.AddAsync(entity, cancellationToken);

                await _context.SaveChangesAsync(cancellationToken);

                return(entity.GroupMessageId);
            }
コード例 #18
0
            public async Task <int> Handle(CreateCommand request, CancellationToken cancellationToken)
            {
                var entity = new ConversationMessage
                {
                    ConversationId = request.Conversation.ConversationId,
                    OwnerUserId    = request.OwnerUserId,
                    Message        = request.Message,
                    Publish        = request.Publish
                };

                await _context.ConversationMessages.AddAsync(entity, cancellationToken);

                entity.Notifications.Add(new CreatedNotification(entity));
                await _context.SaveChangesAsync(cancellationToken);

                return(entity.ConversationMessageId);
            }
コード例 #19
0
ファイル: CreateCommand.cs プロジェクト: JACKHANI/wlodzimierz
            public async Task <int> Handle(CreateCommand request, CancellationToken cancellationToken)
            {
                var entity = new Contact
                {
                    OwnerUserId = request.OwnerUser.UserId,
                    FirstName   = request.FirstName,
                    LastName    = request.LastName,
                    Email       = request.Email,
                    Photo       = request.Photo
                };

                await _context.Contacts.AddAsync(entity, cancellationToken);

                entity.Notifications.Add(new CreatedNotification(entity));
                await _context.SaveChangesAsync(cancellationToken);

                return(entity.ContactId);
            }