shoc-backend/SeaHaven.DataServices/Interfaces/ICommentDataService.cs
npal 6c4de10349 perf(work-orders): delete a work order's comments in one commit
DeleteWorkOrderCascadeAsync deleted comments one at a time: each call
re-fetched the row and committed separately (2N round trips, N commits).
Add DeleteAllForWorkOrderAsync, which loads the set once and removes it in
a single SaveChangesAsync.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-05 20:14:50 -05:00

25 lines
1.2 KiB
C#

using Data.SeaHavenIndustries;
namespace SeaHaven.DataServices.Interfaces
{
public interface ICommentDataService
{
Task<Comments?> GetByIdAsync(int id);
Task<IEnumerable<Comments>> GetAllAsync();
/// <summary>
/// Comments linked to non-deleted, non-template work orders.
/// When <paramref name="accountId"/> is set, only that account's WOs; null = org-wide.
/// </summary>
Task<IEnumerable<Comments>> GetAllForAccountAsync(int? accountId);
Task<IEnumerable<Comments>> GetByWorkOrderIdAsync(int workOrderId);
Task<IEnumerable<Comments>> GetByDispatchIdAsync(int dispatchId);
Task<Comments> AddAsync(Comments comment);
Task UpdateAsync(Comments comment);
Task DeleteAsync(int id);
/// <summary>Deletes every comment on a work order in one statement (no per-row round trip).</summary>
Task DeleteAllForWorkOrderAsync(int workOrderId);
Task<bool> ExistsAsync(int id);
Task StageAsync(Comments comment, CancellationToken cancellationToken);
Task<IReadOnlyList<PortalCommentData>> GetVendorViewableForDispatchAsync(int dispatchId, CancellationToken cancellationToken);
}
}