public async Task <Conversation> ExecuteAsync(IEnumerable <Guid> participantIds) { var foundParticipants = new List <Participant>(); foreach (var id in participantIds) { var participant = await _participantRepository.GetAsync(id); if (participant is null) { throw new Exception($"Participant {participant} not found!"); } foundParticipants.Add(participant); } var newConversation = _conversationsFactory.NewConversation(foundParticipants); await _conversationRepository.AddAsync(newConversation); await _unitOfWork.SaveAsync(); return(newConversation); }
public async Task HandleAsync(CreateNewConversationCommand command) { var conversation = new Conversation(command.Users); await conversationsRepository.AddAsync(conversation); }