Merge branch 'dev' of ssh://test.digitaldrilling.ru:2221/DDrilling/AsbCloudServer into dev

This commit is contained in:
Frolov-Nikita 2023-10-22 19:37:35 +05:00
commit 8715c1b978
No known key found for this signature in database
GPG Key ID: 719E3386D12B0760
2 changed files with 18 additions and 13 deletions

View File

@ -33,7 +33,8 @@ namespace AsbCloudInfrastructure.Services
.Include(w => w.Telemetry) .Include(w => w.Telemetry)
.Include(w => w.WellType) .Include(w => w.WellType)
.Include(w => w.RelationCompaniesWells) .Include(w => w.RelationCompaniesWells)
.ThenInclude(r => r.Company); .ThenInclude(r => r.Company)
.AsNoTracking();
public WellService(IAsbCloudDbContext db, IMemoryCache memoryCache, ITelemetryService telemetryService, ITimezoneService timezoneService, WellInfoService wellInfoService) public WellService(IAsbCloudDbContext db, IMemoryCache memoryCache, ITelemetryService telemetryService, ITimezoneService timezoneService, WellInfoService wellInfoService)
: base(db, memoryCache, MakeQueryWell) : base(db, memoryCache, MakeQueryWell)
@ -105,19 +106,18 @@ namespace AsbCloudInfrastructure.Services
public async Task<WellMapInfoWithTelemetryStat?> GetOrDefaultStatAsync(int idWell, CancellationToken token) public async Task<WellMapInfoWithTelemetryStat?> GetOrDefaultStatAsync(int idWell, CancellationToken token)
{ {
var dto = wellInfoService.FirstOrDefault(well => well.Id == idWell); var well = await GetOrDefaultAsync(idWell, token);
if (dto is not null)
return dto; if (well is null)
var request = new WellRequest{Ids = new[] { idWell }};
var entities = await GetEntitiesAsync(request, token);
var entity = entities.FirstOrDefault();
if (entity is null)
return null; return null;
var wellInfo = wellInfoService.FirstOrDefault(well => well.Id == idWell);
dto = entity.Adapt<WellMapInfoWithTelemetryStat>(); if (wellInfo is null)
return well.Adapt<WellMapInfoWithTelemetryStat>();
return dto;
wellInfo.IdState = well.IdState;
return wellInfo;
} }
public async Task<IEnumerable<WellDto>> GetAsync(WellRequest request, CancellationToken token) public async Task<IEnumerable<WellDto>> GetAsync(WellRequest request, CancellationToken token)

View File

@ -1,4 +1,5 @@
using AsbCloudApp.Data; using AsbCloudApp.Data;
using AsbCloudApp.Exceptions;
using AsbCloudApp.Services; using AsbCloudApp.Services;
using AsbCloudDb.Model; using AsbCloudDb.Model;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
@ -135,7 +136,11 @@ namespace AsbCloudWebApi.Controllers
idWell, token).ConfigureAwait(false)) idWell, token).ConfigureAwait(false))
return Forbid(); return Forbid();
var dto = wellService.GetOrDefault(idWell)!; var dto = await wellService.GetOrDefaultAsync(idWell, token);
if (dto is null)
return this.ValidationBadRequest(nameof(idWell), $"Скважина с id: {idWell} недоступна");
dto.IdState = idState; dto.IdState = idState;
var result = await wellService.UpdateAsync(dto, token) var result = await wellService.UpdateAsync(dto, token)