Files
TenWholeYears.Server/src/RecNet.Infrastructure/Persistence/Repositories/RelationshipRepository.cs
2026-06-26 17:06:15 -05:00

31 lines
1.1 KiB
C#

using Microsoft.EntityFrameworkCore;
using RecNet.Domain.Profiles;
namespace RecNet.Infrastructure.Persistence.Repositories;
public class RelationshipRepository(DatabaseContext dbContext) : IRelationshipRepository
{
public Task<Relationship?> GetAsync(
Guid ownerId,
Guid profileId,
CancellationToken ct = default)
=> dbContext.Relationships
.FirstOrDefaultAsync(x =>
x.OwnerProfileId == ownerId &&
x.ProfileId == profileId,
ct);
public async Task<IReadOnlyList<Relationship>> GetAllOwnedRelationships(Guid ownerId, CancellationToken ct = default)
=> await dbContext.Relationships
.AsNoTracking()
.Where(x => x.OwnerProfileId == ownerId)
.ToListAsync(ct);
public async Task AddAsync(
Relationship relationship,
CancellationToken ct = default)
=> await dbContext.Relationships.AddAsync(relationship, ct);
public Task SaveChangesAsync(CancellationToken ct = default)
=> dbContext.SaveChangesAsync(ct);
}