mirror of
https://github.com/Sea-Haven-Industries/shoc-backend.git
synced 2026-09-30 14:13:12 +00:00
31 lines
1.3 KiB
C#
31 lines
1.3 KiB
C#
|
|
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<WorkOrder?> 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<CompletionDocTemplate?> GetTrackedTemplateAsync(int id, CancellationToken cancellationToken)
|
||
|
|
=> _context.CompletionDocTemplates.FirstOrDefaultAsync(t => t.Id == id && t.IsDeleted != true, cancellationToken);
|
||
|
|
|
||
|
|
public Task SaveAsync(CancellationToken cancellationToken)
|
||
|
|
=> _context.SaveChangesAsync(cancellationToken);
|
||
|
|
}
|
||
|
|
}
|