public virtual async Task Handle(IAddChatCommand <TChatInfo, TParticipationCandidateCollection, TParticipationCandidate> command, IChatBusContext chatEventPublisher) { await ChatsPermissionValidator.ValidateAdd(command.InitiatorUserId, command.ChatId, command.ChatInfo, WorkerName).ConfigureAwait(false); var chat = await ChatStore.Create(command.ChatId, command.ChatInfo, command.ToAdd, command.ToInvite, command.InitiatorUserId).ConfigureAwait(false); var @event = ChatsEventBuilder.BuildChatAddedEvent(command.InitiatorUserId, chat); await chatEventPublisher.EventPublisher.Publish(@event).ConfigureAwait(false); }
public virtual async Task <Guid> Add(Guid currentUserId, Guid?chatId, TChatInfo chatInfo, TParticipationCandidates participationCandidates) { var command = ChatsCommandBuilder.BuildAddChatCommand(currentUserId, chatId, chatInfo, participationCandidates); await ChatsPermissionValidator.ValidateAdd(currentUserId, command.ChatId, chatInfo, ServiceName).ConfigureAwait(false); await ChatCommandSender.Send(command).ConfigureAwait(false); return(command.ChatId); }