private async Task CreateAsync(Contact entity, CancellationToken cancellationToken) { await _context.Contacts.AddAsync(entity, cancellationToken); Notify(entity); await _context.SaveChangesAsync(cancellationToken); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }