diff --git a/AsbCloudApp/Services/IDrillParamsService.cs b/AsbCloudApp/Services/IDrillParamsService.cs index 6c566423..30b28500 100644 --- a/AsbCloudApp/Services/IDrillParamsService.cs +++ b/AsbCloudApp/Services/IDrillParamsService.cs @@ -9,5 +9,8 @@ namespace AsbCloudApp.Services { Task GetDefaultDrillParamsAsync(int idWell, double startDepth, double endDepth, CancellationToken token = default); + + Task> GetAllAsync(int idWell, + CancellationToken token = default); } } diff --git a/AsbCloudInfrastructure/Services/DrillParamsService.cs b/AsbCloudInfrastructure/Services/DrillParamsService.cs index 85e7a42c..d04078f9 100644 --- a/AsbCloudInfrastructure/Services/DrillParamsService.cs +++ b/AsbCloudInfrastructure/Services/DrillParamsService.cs @@ -1,10 +1,12 @@ -using System.Linq; +using System.Collections.Generic; +using System.Linq; using System.Threading; using System.Threading.Tasks; using AsbCloudApp.Data; using AsbCloudApp.Services; using AsbCloudDb.Model; using Microsoft.EntityFrameworkCore; +using Mapster; namespace AsbCloudInfrastructure.Services { @@ -19,6 +21,7 @@ namespace AsbCloudInfrastructure.Services this.db = context; this.telemetryService = telemetryService; } + public async Task GetDefaultDrillParamsAsync(int idWell, double startDepth, double endDepth, CancellationToken token = default) { @@ -110,6 +113,20 @@ namespace AsbCloudInfrastructure.Services FlowMax = flows.Max ?? 0, }; } + + public async Task> GetAllAsync(int idWell, + CancellationToken token = default) + { + var entities = await (from p in db.DrillParams + where p.IdWell == idWell + orderby p.Id + select p) + .ToListAsync(token) + .ConfigureAwait(false); + + var dto = entities.Select(entity => entity.Adapt()); + return dto; + } private IQueryable> GetTelemetryGroupQuery(int idTelemetry, double startDepth, double endDepth) diff --git a/AsbCloudWebApi/Controllers/DrillParamsController.cs b/AsbCloudWebApi/Controllers/DrillParamsController.cs index 4d86a3e2..6220160e 100644 --- a/AsbCloudWebApi/Controllers/DrillParamsController.cs +++ b/AsbCloudWebApi/Controllers/DrillParamsController.cs @@ -66,7 +66,7 @@ namespace AsbCloudWebApi.Controllers idWell, token).ConfigureAwait(false)) return Forbid(); - var dto = await drillParamsService.GetAsync(idWell, token); + var dto = await drillParamsService.GetAllAsync(idWell, token); return Ok(dto); }