Files
TenWholeYears.Server/RecNet.Infrastructure/Persistence/Repositories/ProfileRepository.cs
2026-06-18 13:43:59 -05:00

40 lines
1.3 KiB
C#

using Microsoft.EntityFrameworkCore;
using RecNet.Domain.Common;
using RecNet.Domain.Entities.Profiles;
using RecNet.Domain.Repositories;
namespace RecNet.Infrastructure.Persistence.Repositories;
public class ProfileRepository(DatabaseContext dbContext) : IProfileRepository
{
public Task<Profile?> GetByIdAsync(
Guid profileId,
CancellationToken ct = default)
=> dbContext.Profiles
.FirstOrDefaultAsync(x => x.ProfileId == profileId, ct);
public async Task<IReadOnlyList<Profile>> GetByIdsAsync(
List<Guid> profileIds,
CancellationToken ct = default)
=> await dbContext.Profiles
.Where(x => profileIds.Contains(x.ProfileId))
.ToListAsync(ct);
public Task<Profile?> GetByPlatform(
PlatformType platform,
string platformId,
CancellationToken ct = default)
=> dbContext.Profiles
.FirstOrDefaultAsync(x =>
x.Platform == platform &&
x.PlatformId == platformId,
ct);
public async Task AddAsync(
Profile profile,
CancellationToken ct = default)
=> await dbContext.Profiles.AddAsync(profile, ct);
public Task SaveChangesAsync(CancellationToken ct = default)
=> dbContext.SaveChangesAsync(ct);
}