Files
monorepo/LCU.API.Internal.RepoApi/LCU.API.Internal.RepoApi.Repos/Repositories/Batch/RepoSyncBatchRepository.cs
T
2026-03-13 09:27:34 -05:00

35 lines
1.5 KiB
C#

using LCU.API.Internal.RepoApi.Repos.Persistence;
using LCU.Library.Internal.LcuClassPatterns.Crud.Repositories;
using LCU.Library.Internal.RepoApiModels.Models;
using Microsoft.EntityFrameworkCore;
namespace LCU.API.Internal.RepoApi.Repos.Repositories.Batch;
public class RepoSyncBatchRepository : CrudRepository<RepoSyncBatch>, IRepoSyncBatchRepository
{
private readonly AppDbContext _context;
public RepoSyncBatchRepository(AppDbContext context) : base(context) {
_context = context;
}
public async Task<IEnumerable<RepoSyncBatch>> FindAllByRunInfoIdAsync(int id)
{
return await _context.RepoSyncBatch.Where(repoSyncBatch => repoSyncBatch.RepoSyncRunInfoId == id).ToListAsync();
}
public async Task<RepoSyncBatch> FindByIdAsync(int id)
{
return await _context.RepoSyncBatch.Where(repoSyncBatch => repoSyncBatch.RepoSyncBatchId == id).FirstOrDefaultAsync();
}
public async Task<RepoSyncBatch> FindUncompletedByAuditId(string auditItemKey) =>
await _context.RepoSyncBatch
.Where(repoSyncBatch => repoSyncBatch.AuditItemKey == auditItemKey && repoSyncBatch.RepoSyncCompletionDateTime == null)
.FirstOrDefaultAsync();
public async Task<RepoSyncBatch> FindByBatchIdAndAuditIdAsync(int batchId, string auditItemKey) =>
await _context.RepoSyncBatch
.Where(repoSyncBatch => repoSyncBatch.RepoSyncBatchId == batchId && repoSyncBatch.AuditItemKey == auditItemKey)
.FirstOrDefaultAsync();
}