diff --git a/AsbCloudInfrastructure/Services/DetectOperations/DetectedOperationExportService.cs b/AsbCloudInfrastructure/Services/DetectOperations/DetectedOperationExportService.cs
index a94726c1..b70f8cd4 100644
--- a/AsbCloudInfrastructure/Services/DetectOperations/DetectedOperationExportService.cs
+++ b/AsbCloudInfrastructure/Services/DetectOperations/DetectedOperationExportService.cs
@@ -12,6 +12,7 @@ using AsbCloudApp.Data.DetectedOperation;
using AsbCloudInfrastructure.Services.DetectOperations.Detectors;
using AsbCloudApp.Repositories;
using Microsoft.AspNetCore.Http.Extensions;
+using AsbCloudApp.Exceptions;
namespace AsbCloudInfrastructure.Services.DetectOperations;
@@ -57,21 +58,21 @@ public class DetectedOperationExportService
/// ั
ะพัั
///
///
- ///
+ ///
public async Task ExportAsync(int idWell, string host, CancellationToken cancellationToken)
{
- var well = await dbContext.Wells
+ var well = await dbContext.Set()
.Include(w => w.Cluster)
.ThenInclude(c => c.Deposit)
- .SingleOrDefaultAsync(w => w.Id == idWell, cancellationToken);
+ .FirstOrDefaultAsync(w => w.Id == idWell, cancellationToken);
if (well is null)
- throw new ArgumentNullException(nameof(well));
+ throw new ArgumentInvalidException(nameof(idWell), $"Well {idWell} does not exist");
if (!well.IdTelemetry.HasValue)
- throw new ArgumentNullException(nameof(well));
+ throw new ArgumentInvalidException(nameof(idWell), $"Well {idWell} has no telemetry");
- var operations = await DetectOperationsAsync(well.IdTelemetry.Value, DateTime.UnixEpoch, cancellationToken);
+ var operations = await DetectOperationsAsync(well.IdTelemetry.Value, DateTime.UnixEpoch, cancellationToken);
return await GenerateExcelFileStreamAsync(well, host, operations, cancellationToken);
}