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, IRepoSyncBatchRepository { private readonly AppDbContext _context; public RepoSyncBatchRepository(AppDbContext context) : base(context) { _context = context; } public async Task> FindAllByRunInfoIdAsync(int id) { return await _context.RepoSyncBatch.Where(repoSyncBatch => repoSyncBatch.RepoSyncRunInfoId == id).ToListAsync(); } public async Task FindByIdAsync(int id) { return await _context.RepoSyncBatch.Where(repoSyncBatch => repoSyncBatch.RepoSyncBatchId == id).FirstOrDefaultAsync(); } public async Task FindUncompletedByAuditId(string auditItemKey) => await _context.RepoSyncBatch .Where(repoSyncBatch => repoSyncBatch.AuditItemKey == auditItemKey && repoSyncBatch.RepoSyncCompletionDateTime == null) .FirstOrDefaultAsync(); public async Task FindByBatchIdAndAuditIdAsync(int batchId, string auditItemKey) => await _context.RepoSyncBatch .Where(repoSyncBatch => repoSyncBatch.RepoSyncBatchId == batchId && repoSyncBatch.AuditItemKey == auditItemKey) .FirstOrDefaultAsync(); }