public void AddMember(Guid userId) { if (!IsGroupConversation) { throw new InvalidOperationException($"Conversation with ID: {Id} is not group conversation"); } if (!Members.Exists(cm => cm.UserId == userId)) { Members.Add(ConversationMember.Create(Id, userId)); } }
public static Conversation CreateDirectConversation(Guid firstMember, Guid secondMember) { var conversation = new Conversation { Id = Guid.NewGuid(), StartDateTime = DateTime.Now, IsGroupConversation = false }; conversation.Members.Add(ConversationMember.Create(conversation.Id, firstMember)); conversation.Members.Add(ConversationMember.Create(conversation.Id, secondMember)); return(conversation); }
public static Conversation CreateGroupConversation(IEnumerable <Guid> members) { var conversation = new Conversation { Id = new Guid(), StartDateTime = DateTime.Now, IsGroupConversation = true }; conversation.Members = members .Select(m => ConversationMember.Create(conversation.Id, m)) .ToList(); return(conversation); }