Add relationships feature and EF migration

This commit is contained in:
Holden
2026-06-26 17:06:15 -05:00
parent dbe33f3148
commit b3028ce741
30 changed files with 536 additions and 8 deletions

View File

@@ -0,0 +1,31 @@
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);
}