mirror of
https://github.com/Sea-Haven-Industries/shoc-backend.git
synced 2026-09-30 22:23:12 +00:00
31 lines
1.2 KiB
C#
31 lines
1.2 KiB
C#
|
|
using Data.SeaHavenIndustries;
|
||
|
|
using Microsoft.EntityFrameworkCore;
|
||
|
|
using SeaHaven.DataServices.Interfaces;
|
||
|
|
|
||
|
|
namespace SeaHaven.DataServices.Implementation
|
||
|
|
{
|
||
|
|
public class WorkOrderMediaDataService : IWorkOrderMediaDataService
|
||
|
|
{
|
||
|
|
private readonly ApplicationDbContext _context;
|
||
|
|
|
||
|
|
public WorkOrderMediaDataService(ApplicationDbContext context)
|
||
|
|
{
|
||
|
|
_context = context;
|
||
|
|
}
|
||
|
|
|
||
|
|
public Task<WorkOrder?> GetTrackedWorkOrderAsync(int workOrderId, CancellationToken cancellationToken)
|
||
|
|
=> _context.workOrders.FirstOrDefaultAsync(w => w.Id == workOrderId, cancellationToken);
|
||
|
|
|
||
|
|
public Task<WorkOrderAttachments?> GetTrackedAttachmentAsync(int mediaId, int workOrderId, CancellationToken cancellationToken)
|
||
|
|
=> _context.workOrderAttachments.FirstOrDefaultAsync(
|
||
|
|
a => a.Id == mediaId && a.WorkorderId == workOrderId && a.IsDeleted != true,
|
||
|
|
cancellationToken);
|
||
|
|
|
||
|
|
public void TrackAttachment(WorkOrderAttachments attachment)
|
||
|
|
=> _context.workOrderAttachments.Add(attachment);
|
||
|
|
|
||
|
|
public Task SaveAsync(CancellationToken cancellationToken)
|
||
|
|
=> _context.SaveChangesAsync(cancellationToken);
|
||
|
|
}
|
||
|
|
}
|