using Data.SeaHavenIndustries; using Microsoft.EntityFrameworkCore; using SeaHaven.DataServices.Interfaces; namespace SeaHaven.DataServices.Implementation { public class WorkOrderCompletionDataService : IWorkOrderCompletionDataService { private readonly ApplicationDbContext _context; public WorkOrderCompletionDataService(ApplicationDbContext context) { _context = context; } public Task GetTrackedWorkOrderAsync(int workOrderId, CancellationToken cancellationToken) => _context.workOrders.FirstOrDefaultAsync( w => w.Id == workOrderId && w.istemplate != true && (w.IsDeleted != true || w.IsDeleted == null), cancellationToken); public void SetExpectedWorkOrderVersion(WorkOrder workOrder, byte[] version) => _context.Entry(workOrder).Property(w => w.RowVersion).OriginalValue = version; public Task GetTrackedTemplateAsync(int id, CancellationToken cancellationToken) => _context.CompletionDocTemplates.FirstOrDefaultAsync(t => t.Id == id && t.IsDeleted != true, cancellationToken); public Task SaveAsync(CancellationToken cancellationToken) => _context.SaveChangesAsync(cancellationToken); } }