This commit is contained in:
Фролов 2021-10-12 12:17:58 +05:00
commit f7fedb16e8
3 changed files with 22 additions and 2 deletions

View File

@ -9,5 +9,8 @@ namespace AsbCloudApp.Services
{ {
Task<DrillParamsDto> GetDefaultDrillParamsAsync(int idWell, double startDepth, Task<DrillParamsDto> GetDefaultDrillParamsAsync(int idWell, double startDepth,
double endDepth, CancellationToken token = default); double endDepth, CancellationToken token = default);
Task<IEnumerable<DrillParamsDto>> GetAllAsync(int idWell,
CancellationToken token = default);
} }
} }

View File

@ -1,10 +1,12 @@
using System.Linq; using System.Collections.Generic;
using System.Linq;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using AsbCloudApp.Data; using AsbCloudApp.Data;
using AsbCloudApp.Services; using AsbCloudApp.Services;
using AsbCloudDb.Model; using AsbCloudDb.Model;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Mapster;
namespace AsbCloudInfrastructure.Services namespace AsbCloudInfrastructure.Services
{ {
@ -19,6 +21,7 @@ namespace AsbCloudInfrastructure.Services
this.db = context; this.db = context;
this.telemetryService = telemetryService; this.telemetryService = telemetryService;
} }
public async Task<DrillParamsDto> GetDefaultDrillParamsAsync(int idWell, public async Task<DrillParamsDto> GetDefaultDrillParamsAsync(int idWell,
double startDepth, double endDepth, CancellationToken token = default) double startDepth, double endDepth, CancellationToken token = default)
{ {
@ -111,6 +114,20 @@ namespace AsbCloudInfrastructure.Services
}; };
} }
public async Task<IEnumerable<DrillParamsDto>> 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<DrillParamsDto>());
return dto;
}
private IQueryable<IGrouping<int, TelemetryDataSaub>> GetTelemetryGroupQuery(int idTelemetry, private IQueryable<IGrouping<int, TelemetryDataSaub>> GetTelemetryGroupQuery(int idTelemetry,
double startDepth, double endDepth) double startDepth, double endDepth)
{ {

View File

@ -66,7 +66,7 @@ namespace AsbCloudWebApi.Controllers
idWell, token).ConfigureAwait(false)) idWell, token).ConfigureAwait(false))
return Forbid(); return Forbid();
var dto = await drillParamsService.GetAsync(idWell, token); var dto = await drillParamsService.GetAllAsync(idWell, token);
return Ok(dto); return Ok(dto);
} }