forked from ddrilling/AsbCloudServer
Merge pull request 'Добавление и обновление скважины' (#69) from feature/fix_add_and_update_well into dev
Reviewed-on: http://test.digitaldrilling.ru:8080/DDrilling/AsbCloudServer/pulls/69
This commit is contained in:
commit
65a7e072d6
@ -126,8 +126,11 @@ namespace AsbCloudInfrastructure.Services
|
||||
return wells;
|
||||
}
|
||||
|
||||
public override async Task<int> InsertAsync(WellDto dto, CancellationToken token = default)
|
||||
public override async Task<int> InsertAsync(WellDto dto, CancellationToken token)
|
||||
{
|
||||
if (IsTelemetryAssignedToDifferentWell(dto))
|
||||
throw new ArgumentInvalidException("Телеметрия уже была привязана к другой скважине.", nameof(dto));
|
||||
|
||||
if (dto.IdWellType is < 1 or > 2)
|
||||
throw new ArgumentInvalidException("Тип скважины указан неправильно.", nameof(dto));
|
||||
|
||||
@ -157,9 +160,12 @@ namespace AsbCloudInfrastructure.Services
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override async Task<int> UpdateAsync(WellDto dto,
|
||||
CancellationToken token = default)
|
||||
public override async Task<int> UpdateAsync(WellDto dto,
|
||||
CancellationToken token)
|
||||
{
|
||||
if (IsTelemetryAssignedToDifferentWell(dto))
|
||||
throw new ArgumentInvalidException("Телеметрия уже была привязана к другой скважине.", nameof(dto));
|
||||
|
||||
if (dto.IdWellType is < 1 or > 2)
|
||||
throw new ArgumentInvalidException("Тип скважины указан неправильно.", nameof(dto));
|
||||
|
||||
@ -335,6 +341,20 @@ namespace AsbCloudInfrastructure.Services
|
||||
throw new Exception($"Can't find timezone for well {wellDto.Caption} id: {wellDto.Id}");
|
||||
}
|
||||
|
||||
private bool IsTelemetryAssignedToDifferentWell(WellDto wellDto)
|
||||
{
|
||||
if (!wellDto.IdTelemetry.HasValue)
|
||||
return false;
|
||||
|
||||
var existingWellWithAssignedTelemetry = GetCache()
|
||||
.FirstOrDefault(x => x.IdTelemetry == wellDto.IdTelemetry);
|
||||
|
||||
if (existingWellWithAssignedTelemetry is null)
|
||||
return false;
|
||||
|
||||
return existingWellWithAssignedTelemetry.Id != wellDto.Id;
|
||||
}
|
||||
|
||||
private static AsbCloudDb.Model.IMapPoint GetCoordinates(Well well)
|
||||
{
|
||||
if (well is null)
|
||||
|
Loading…
Reference in New Issue
Block a user