using MessageService.Domain.Entities; using MessageService.Domain.IReposities; using Microsoft.EntityFrameworkCore; namespace MessageService.Infrastructure.Reposities { public class ConversationReposity : IConversationReposity { private readonly MessageDbContext db; public ConversationReposity(MessageDbContext db) { this.db = db; } public void Create(Conversation conversation) { db.Conversations.Add(conversation); } public async Task> FindAllStreamKeyAsync(Guid userId) { return await db.Conversations.Where(x => x.UserId == userId) .Select(s => s.StreamKey) .ToListAsync(); } public async Task FindByIdAsync(Guid id) { return await db.Conversations.FirstOrDefaultAsync(x => x.Id == id); } public async Task> FindByStreamKeyAsync(string streamKey) { return await db.Conversations.Where(x => x.StreamKey == streamKey).ToListAsync(); } public async Task> FindByTargetIdAsync(Guid targetId) { return await db.Conversations.Where(x => x.TargetId == targetId).ToListAsync(); } public async Task> FindByUserIdAsync(Guid userId) { return await db.Conversations.Where(x => x.UserId == userId).ToListAsync(); } } }