forked from ddrilling/AsbCloudServer
finally refact
This commit is contained in:
parent
5c00e996f5
commit
0b3825a531
@ -19,7 +19,7 @@ namespace AsbCloudApp.Services
|
|||||||
/// Получить имя файла (исходя из названия скважины)
|
/// Получить имя файла (исходя из названия скважины)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
string GetFileName(int idWell, CancellationToken token);
|
string GetFileNameAsync(int idWell, CancellationToken token);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// загрузить текущую плановую траекторию в .xlsx
|
/// загрузить текущую плановую траекторию в .xlsx
|
||||||
@ -35,8 +35,8 @@ namespace AsbCloudApp.Services
|
|||||||
/// <param name="idUser"></param>
|
/// <param name="idUser"></param>
|
||||||
/// <param name="stream"></param>
|
/// <param name="stream"></param>
|
||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <param name="deletePlannedTrajectoryBeforeImport">Очистить старые координаты перед импортом (если файл проходит валидацию)</param>
|
/// <param name="deleteBeforeImport">Очистить старые координаты перед импортом (если файл проходит валидацию)</param>
|
||||||
Task<int> ImportAsync(int idWell, int idUser, Stream stream, CancellationToken token, bool deletePlannedTrajectoryBeforeImport = false);
|
Task<int> ImportAsync(int idWell, int idUser, Stream stream, bool deleteBeforeImport, CancellationToken token);
|
||||||
}
|
}
|
||||||
#nullable disable
|
#nullable disable
|
||||||
}
|
}
|
||||||
|
@ -38,12 +38,11 @@ namespace AsbCloudApp.Services
|
|||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Обновить строку с координатами
|
/// Обновить строку с координатами
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="idRow"></param>
|
|
||||||
/// <param name="row"></param>
|
/// <param name="row"></param>
|
||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<int> UpdateAsync(int idRow, PlannedTrajectoryDto row,
|
Task<int> UpdateAsync(PlannedTrajectoryDto row,
|
||||||
CancellationToken token);
|
CancellationToken token);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -13,7 +13,7 @@ namespace AsbCloudDb.Model
|
|||||||
public virtual DbSet<DailyReport.DailyReport> DailyReports => Set <DailyReport.DailyReport >();
|
public virtual DbSet<DailyReport.DailyReport> DailyReports => Set <DailyReport.DailyReport >();
|
||||||
public virtual DbSet<Deposit> Deposits => Set<Deposit>();
|
public virtual DbSet<Deposit> Deposits => Set<Deposit>();
|
||||||
public virtual DbSet<DetectedOperation> DetectedOperations => Set<DetectedOperation>();
|
public virtual DbSet<DetectedOperation> DetectedOperations => Set<DetectedOperation>();
|
||||||
public virtual DbSet<PlannedTrajectory> PlannedTrajectorys => Set<PlannedTrajectory>();
|
public virtual DbSet<PlannedTrajectory> PlannedTrajectories => Set<PlannedTrajectory>();
|
||||||
public virtual DbSet<ProcessMap> ProcessMap => Set<ProcessMap>();
|
public virtual DbSet<ProcessMap> ProcessMap => Set<ProcessMap>();
|
||||||
public virtual DbSet<DrillingProgramPart> DrillingProgramParts => Set<DrillingProgramPart>();
|
public virtual DbSet<DrillingProgramPart> DrillingProgramParts => Set<DrillingProgramPart>();
|
||||||
public virtual DbSet<FileCategory> FileCategories => Set<FileCategory>();
|
public virtual DbSet<FileCategory> FileCategories => Set<FileCategory>();
|
||||||
|
@ -15,7 +15,7 @@ namespace AsbCloudDb.Model
|
|||||||
DbSet<DailyReport.DailyReport> DailyReports { get; }
|
DbSet<DailyReport.DailyReport> DailyReports { get; }
|
||||||
DbSet<Deposit> Deposits { get; }
|
DbSet<Deposit> Deposits { get; }
|
||||||
DbSet<DetectedOperation> DetectedOperations { get; }
|
DbSet<DetectedOperation> DetectedOperations { get; }
|
||||||
DbSet<PlannedTrajectory> PlannedTrajectorys { get; }
|
DbSet<PlannedTrajectory> PlannedTrajectories { get; }
|
||||||
DbSet<ProcessMap> ProcessMap { get; }
|
DbSet<ProcessMap> ProcessMap { get; }
|
||||||
DbSet<DrillingProgramPart> DrillingProgramParts { get; }
|
DbSet<DrillingProgramPart> DrillingProgramParts { get; }
|
||||||
DbSet<FileCategory> FileCategories { get; }
|
DbSet<FileCategory> FileCategories { get; }
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
<None Remove="CommonLibs\logo_720x404.png" />
|
<None Remove="CommonLibs\logo_720x404.png" />
|
||||||
<None Remove="CommonLibs\Readme.md" />
|
<None Remove="CommonLibs\Readme.md" />
|
||||||
<None Remove="Services\DailyReport\DailyReportTemplate.xlsx" />
|
<None Remove="Services\DailyReport\DailyReportTemplate.xlsx" />
|
||||||
<None Remove="Services\PlannedTrajectoryService\PlannedTrajectoryTemplate.xlsx" />
|
<None Remove="Services\PlannedTrajectory\PlannedTrajectoryTemplate.xlsx" />
|
||||||
<None Remove="Services\WellOperationService\ScheduleReportTemplate.xlsx" />
|
<None Remove="Services\WellOperationService\ScheduleReportTemplate.xlsx" />
|
||||||
<None Remove="Services\WellOperationService\WellOperationImportTemplate.xlsx" />
|
<None Remove="Services\WellOperationService\WellOperationImportTemplate.xlsx" />
|
||||||
<None Remove="Services\DailyReport\DailyReportBlocks\" />
|
<None Remove="Services\DailyReport\DailyReportBlocks\" />
|
||||||
@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<EmbeddedResource Include="Services\DailyReport\DailyReportTemplate.xlsx" />
|
<EmbeddedResource Include="Services\DailyReport\DailyReportTemplate.xlsx" />
|
||||||
<EmbeddedResource Include="Services\PlannedTrajectoryService\PlannedTrajectoryTemplate.xlsx" />
|
<EmbeddedResource Include="Services\PlannedTrajectory\PlannedTrajectoryTemplate.xlsx" />
|
||||||
<EmbeddedResource Include="Services\WellOperationService\ScheduleReportTemplate.xlsx" />
|
<EmbeddedResource Include="Services\WellOperationService\ScheduleReportTemplate.xlsx" />
|
||||||
<EmbeddedResource Include="Services\WellOperationService\WellOperationImportTemplate.xlsx" />
|
<EmbeddedResource Include="Services\WellOperationService\WellOperationImportTemplate.xlsx" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
@ -56,7 +56,7 @@ namespace AsbCloudInfrastructure.Services.PlannedTrajectory
|
|||||||
return stream;
|
return stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetFileName (int idWell, CancellationToken token)
|
public string GetFileNameAsync (int idWell, CancellationToken token)
|
||||||
{
|
{
|
||||||
var fileName = wellService.GetWellCaptionByIdAsync(idWell, token) + "_plannedTrajectory.xlsx";
|
var fileName = wellService.GetWellCaptionByIdAsync(idWell, token) + "_plannedTrajectory.xlsx";
|
||||||
return fileName;
|
return fileName;
|
||||||
@ -118,18 +118,18 @@ namespace AsbCloudInfrastructure.Services.PlannedTrajectory
|
|||||||
row.Cell(ColumnComment).Value = trajectory.Comment;
|
row.Cell(ColumnComment).Value = trajectory.Comment;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<int> ImportAsync(int idWell, int idUser, Stream stream, CancellationToken token, bool deletePrevRows = false)
|
public async Task<int> ImportAsync(int idWell, int idUser, Stream stream, bool deletePrevRows, CancellationToken token)
|
||||||
{
|
{
|
||||||
using var workbook = new XLWorkbook(stream, XLEventTracking.Disabled);
|
using var workbook = new XLWorkbook(stream, XLEventTracking.Disabled);
|
||||||
var trajectoryRows = ParseFileStream(stream);
|
var trajectoryRows = ParseFileStream(stream);
|
||||||
foreach (var row in trajectoryRows)
|
foreach (var row in trajectoryRows)
|
||||||
row.IdWell = idWell;
|
row.IdWell = idWell;
|
||||||
|
|
||||||
var rowsCount = await SavePlannedTrajectoryAsync(idWell,trajectoryRows, token, deletePrevRows);
|
var rowsCount = await SavePlannedTrajectoryAsync(idWell,trajectoryRows, deletePrevRows, token);
|
||||||
return rowsCount;
|
return rowsCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<int> SavePlannedTrajectoryAsync(int idWell, IEnumerable<PlannedTrajectoryDto> newRows, CancellationToken token, bool deletePrevRow = false)
|
private async Task<int> SavePlannedTrajectoryAsync(int idWell, IEnumerable<PlannedTrajectoryDto> newRows, bool deletePrevRow, CancellationToken token)
|
||||||
{
|
{
|
||||||
if (deletePrevRow)
|
if (deletePrevRow)
|
||||||
{
|
{
|
@ -22,96 +22,93 @@ namespace AsbCloudInfrastructure.Services.PlannedTrajectory
|
|||||||
this.db = db;
|
this.db = db;
|
||||||
this.wellService = wellService;
|
this.wellService = wellService;
|
||||||
}
|
}
|
||||||
|
/// <inheritdoc/>
|
||||||
public async Task<int> AddRangeAsync(IEnumerable<PlannedTrajectoryDto> plannedTrajectoryRows, CancellationToken token)
|
public async Task<int> AddRangeAsync(IEnumerable<PlannedTrajectoryDto> plannedTrajectoryRows, CancellationToken token)
|
||||||
{
|
{
|
||||||
|
var idWell = plannedTrajectoryRows.First().IdWell;
|
||||||
|
var offsetHours = wellService.GetTimezone(idWell).Hours;
|
||||||
var entitys = plannedTrajectoryRows
|
var entitys = plannedTrajectoryRows
|
||||||
.Select(e => Convert(e));
|
.Select(e => Convert(e, offsetHours));
|
||||||
db.PlannedTrajectorys.AddRange(entitys);
|
foreach(var item in entitys)
|
||||||
|
{
|
||||||
|
item.Id = 0;
|
||||||
|
}
|
||||||
|
db.PlannedTrajectories.AddRange(entitys);
|
||||||
return await db.SaveChangesAsync(token)
|
return await db.SaveChangesAsync(token)
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
public async Task<int> AddAsync(PlannedTrajectoryDto plannedTrajectoryRow, CancellationToken token)
|
public async Task<int> AddAsync(PlannedTrajectoryDto plannedTrajectoryRow, CancellationToken token)
|
||||||
{
|
{
|
||||||
var entity = Convert(plannedTrajectoryRow);
|
var offsetHours = wellService.GetTimezone(plannedTrajectoryRow.IdWell).Hours;
|
||||||
db.PlannedTrajectorys.Add(entity);
|
var entity = Convert(plannedTrajectoryRow, offsetHours);
|
||||||
|
entity.Id = 0;
|
||||||
|
db.PlannedTrajectories.Add(entity);
|
||||||
return await db.SaveChangesAsync(token)
|
return await db.SaveChangesAsync(token)
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
public async Task<int> DeleteRangeAsync(IEnumerable<int> ids, CancellationToken token)
|
public async Task<int> DeleteRangeAsync(IEnumerable<int> ids, CancellationToken token)
|
||||||
{
|
{
|
||||||
var query = db.PlannedTrajectorys
|
var query = db.PlannedTrajectories
|
||||||
.Where(e => ids.Contains(e.Id));
|
.Where(e => ids.Contains(e.Id));
|
||||||
db.PlannedTrajectorys.RemoveRange(query);
|
db.PlannedTrajectories.RemoveRange(query);
|
||||||
return await db.SaveChangesAsync(token)
|
return await db.SaveChangesAsync(token)
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
public async Task<int> DeleteByIdWellAsync(int idWell, CancellationToken token)
|
public async Task<int> DeleteByIdWellAsync(int idWell, CancellationToken token)
|
||||||
{
|
{
|
||||||
var query = db.PlannedTrajectorys
|
var query = db.PlannedTrajectories
|
||||||
.Where(e => e.IdWell == idWell);
|
.Where(e => e.IdWell == idWell);
|
||||||
db.PlannedTrajectorys.RemoveRange(query);
|
db.PlannedTrajectories.RemoveRange(query);
|
||||||
return await db.SaveChangesAsync(token)
|
return await db.SaveChangesAsync(token)
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
public async Task<IEnumerable<PlannedTrajectoryDto>> GetAsync(int idWell, CancellationToken token)
|
public async Task<IEnumerable<PlannedTrajectoryDto>> GetAsync(int idWell, CancellationToken token)
|
||||||
{
|
{
|
||||||
var well = wellService.GetOrDefault(idWell);
|
var well = wellService.GetOrDefault(idWell);
|
||||||
var timezone = wellService.GetTimezone(idWell);
|
var offsetHours = wellService.GetTimezone(idWell).Hours;
|
||||||
if (well is null || well.Timezone is null)
|
if (well is null || well.Timezone is null)
|
||||||
throw new ArgumentInvalidException("idWell doesn`t exist", nameof(idWell));
|
throw new ArgumentInvalidException("idWell doesn`t exist", nameof(idWell));
|
||||||
var query = db.PlannedTrajectorys
|
var query = db.PlannedTrajectories
|
||||||
.AsNoTracking()
|
.AsNoTracking()
|
||||||
.Where(x => x.IdWell == idWell);
|
.Where(x => x.IdWell == idWell);
|
||||||
var entities = await query
|
var entities = await query
|
||||||
.OrderBy(e => e.UpdateDate)
|
.OrderBy(e => e.UpdateDate)
|
||||||
.ToListAsync(token);
|
.ToListAsync(token);
|
||||||
var result = entities
|
var result = entities
|
||||||
.Select(r => Convert(r));
|
.Select(r => Convert(r, offsetHours));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<int> UpdateAsync(int idRow, PlannedTrajectoryDto row, CancellationToken token)
|
/// <inheritdoc/>
|
||||||
|
public async Task<int> UpdateAsync(PlannedTrajectoryDto row, CancellationToken token)
|
||||||
{
|
{
|
||||||
var entity = Convert(row, idRow);
|
var entity = Convert(row, row.Id);
|
||||||
db.PlannedTrajectorys.Update(entity);
|
db.PlannedTrajectories.Update(entity);
|
||||||
return await db.SaveChangesAsync(token)
|
return await db.SaveChangesAsync(token)
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private PlannedTrajectoryDto Convert(AsbCloudDb.Model.PlannedTrajectory entity)
|
private PlannedTrajectoryDto Convert(AsbCloudDb.Model.PlannedTrajectory entity, double offsetHours)
|
||||||
{
|
{
|
||||||
var timezone = wellService.GetTimezone(entity.IdWell);
|
|
||||||
var dto = entity.Adapt<PlannedTrajectoryDto>();
|
var dto = entity.Adapt<PlannedTrajectoryDto>();
|
||||||
dto.UpdateDate = entity.UpdateDate.ToRemoteDateTime(timezone.Hours);
|
dto.UpdateDate = entity.UpdateDate.ToRemoteDateTime(offsetHours);
|
||||||
return dto;
|
return dto;
|
||||||
}
|
}
|
||||||
|
|
||||||
private AsbCloudDb.Model.PlannedTrajectory Convert(PlannedTrajectoryDto dto)
|
private AsbCloudDb.Model.PlannedTrajectory Convert(PlannedTrajectoryDto dto, double offsetHours)
|
||||||
{
|
{
|
||||||
var timezone = wellService.GetTimezone(dto.IdWell);
|
|
||||||
var entity = dto.Adapt<AsbCloudDb.Model.PlannedTrajectory>();
|
var entity = dto.Adapt<AsbCloudDb.Model.PlannedTrajectory>();
|
||||||
entity.IdWell = dto.IdWell;
|
entity.UpdateDate = DateTime.Now.ToUtcDateTimeOffset(offsetHours);
|
||||||
entity.Id = 0;
|
|
||||||
entity.UpdateDate = DateTime.Now.ToUtcDateTimeOffset(timezone.Hours);
|
|
||||||
entity.IdUser = dto.IdUser;
|
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
private AsbCloudDb.Model.PlannedTrajectory Convert(PlannedTrajectoryDto dto, int idRow)
|
|
||||||
{
|
|
||||||
var timezone = wellService.GetTimezone(dto.IdWell);
|
|
||||||
var entity = dto.Adapt<AsbCloudDb.Model.PlannedTrajectory>();
|
|
||||||
entity.IdWell = dto.IdWell;
|
|
||||||
entity.Id = idRow;
|
|
||||||
entity.UpdateDate = DateTime.Now.ToUtcDateTimeOffset(timezone.Hours);
|
|
||||||
entity.IdUser = dto.IdUser;
|
|
||||||
return entity;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#nullable disable
|
#nullable disable
|
||||||
}
|
}
|
@ -61,7 +61,7 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
token).ConfigureAwait(false))
|
token).ConfigureAwait(false))
|
||||||
return Forbid();
|
return Forbid();
|
||||||
var stream = await plannedTrajectoryImportService.ExportAsync(idWell, token);
|
var stream = await plannedTrajectoryImportService.ExportAsync(idWell, token);
|
||||||
var fileName = plannedTrajectoryImportService.GetFileName(idWell, token);
|
var fileName = plannedTrajectoryImportService.GetFileNameAsync(idWell, token);
|
||||||
return File(stream, "application/octet-stream", fileName);
|
return File(stream, "application/octet-stream", fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,6 +76,7 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Permission]
|
[Permission]
|
||||||
[Route("import/{options}")]
|
[Route("import/{options}")]
|
||||||
|
[ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)]
|
||||||
public async Task<IActionResult> ImportAsync(int idWell,
|
public async Task<IActionResult> ImportAsync(int idWell,
|
||||||
[FromForm] IFormFileCollection files,
|
[FromForm] IFormFileCollection files,
|
||||||
int options = 0,
|
int options = 0,
|
||||||
@ -96,7 +97,7 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var result = plannedTrajectoryImportService.ImportAsync(idWell, idUser.Value, stream, token, (options & 1) > 0);
|
var result = plannedTrajectoryImportService.ImportAsync(idWell, idUser.Value, stream, (options & 1) > 0, token);
|
||||||
return Ok(result);
|
return Ok(result);
|
||||||
}
|
}
|
||||||
catch (FileFormatException ex)
|
catch (FileFormatException ex)
|
||||||
@ -110,12 +111,12 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="idWell">id скважины</param>
|
/// <param name="idWell">id скважины</param>
|
||||||
/// <param name="token"> Токен отмены задачи </param>
|
/// <param name="token"> Токен отмены задачи </param>
|
||||||
/// <returns>Запрашиваемый файл</returns>
|
/// <returns>Список добавленных координат плановой траектории</returns>
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[Route("allRows")]
|
[Route("getRows")]
|
||||||
[Permission]
|
[Permission]
|
||||||
[ProducesResponseType(typeof(IEnumerable<PlannedTrajectoryDto>), (int)System.Net.HttpStatusCode.OK)]
|
[ProducesResponseType(typeof(IEnumerable<PlannedTrajectoryDto>), (int)System.Net.HttpStatusCode.OK)]
|
||||||
public async Task<IActionResult> GetRows([FromRoute] int idWell, CancellationToken token = default)
|
public async Task<IActionResult> GetAsync([FromRoute] int idWell, CancellationToken token = default)
|
||||||
{
|
{
|
||||||
if (!await CanUserAccessToWellAsync(idWell,
|
if (!await CanUserAccessToWellAsync(idWell,
|
||||||
token).ConfigureAwait(false))
|
token).ConfigureAwait(false))
|
||||||
@ -134,13 +135,13 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Route("addRow")]
|
[Route("addRow")]
|
||||||
[Permission]
|
[Permission]
|
||||||
[ProducesResponseType(typeof(PlannedTrajectoryDto), (int)System.Net.HttpStatusCode.OK)]
|
[ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)]
|
||||||
public async Task<IActionResult> AddRowAsync(int idWell, [FromBody] PlannedTrajectoryDto row,
|
public async Task<IActionResult> AddAsync(int idWell, [FromBody] PlannedTrajectoryDto row,
|
||||||
CancellationToken token = default)
|
CancellationToken token = default)
|
||||||
{
|
{
|
||||||
if (!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false))
|
if (!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false))
|
||||||
return Forbid();
|
return Forbid();
|
||||||
int? idUser = User.GetUserId();
|
var idUser = User.GetUserId();
|
||||||
if (!idUser.HasValue)
|
if (!idUser.HasValue)
|
||||||
return Forbid();
|
return Forbid();
|
||||||
row.IdUser = idUser.Value;
|
row.IdUser = idUser.Value;
|
||||||
@ -160,8 +161,8 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Route("addRangeRows")]
|
[Route("addRangeRows")]
|
||||||
[Permission]
|
[Permission]
|
||||||
[ProducesResponseType(typeof(IEnumerable<PlannedTrajectoryDto>), (int)System.Net.HttpStatusCode.OK)]
|
[ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)]
|
||||||
public async Task<IActionResult> AddRangeRowsAsync(int idWell, [FromBody] IEnumerable<PlannedTrajectoryDto> rows,
|
public async Task<IActionResult> AddRangeAsync(int idWell, [FromBody] IEnumerable<PlannedTrajectoryDto> rows,
|
||||||
CancellationToken token = default)
|
CancellationToken token = default)
|
||||||
{
|
{
|
||||||
if (!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false))
|
if (!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false))
|
||||||
@ -183,14 +184,13 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
/// Изменить выбранную строку с координатами
|
/// Изменить выбранную строку с координатами
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="idWell"></param>
|
/// <param name="idWell"></param>
|
||||||
/// <param name="idRow"></param>
|
|
||||||
/// <param name="row"></param>
|
/// <param name="row"></param>
|
||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns>количество успешно обновленных строк в БД</returns>
|
/// <returns>количество успешно обновленных строк в БД</returns>
|
||||||
[HttpPut("{idRow}")]
|
[HttpPut("{idRow}")]
|
||||||
[Permission]
|
[Permission]
|
||||||
[ProducesResponseType(typeof(PlannedTrajectoryDto), (int)System.Net.HttpStatusCode.OK)]
|
[ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)]
|
||||||
public async Task<IActionResult> UpdateRowAsync(int idWell, int idRow,
|
public async Task<IActionResult> UpdateAsync(int idWell,
|
||||||
[FromBody] PlannedTrajectoryDto row, CancellationToken token = default)
|
[FromBody] PlannedTrajectoryDto row, CancellationToken token = default)
|
||||||
{
|
{
|
||||||
if (!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false))
|
if (!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false))
|
||||||
@ -200,7 +200,7 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
return Forbid();
|
return Forbid();
|
||||||
row.IdUser = idUser.Value;
|
row.IdUser = idUser.Value;
|
||||||
row.IdWell = idWell;
|
row.IdWell = idWell;
|
||||||
var result = await plannedTrajectoryService.UpdateAsync(idRow, row, token)
|
var result = await plannedTrajectoryService.UpdateAsync(row, token)
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
return Ok(result);
|
return Ok(result);
|
||||||
}
|
}
|
||||||
@ -215,7 +215,7 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
[HttpDelete("{idRow}")]
|
[HttpDelete("{idRow}")]
|
||||||
[Permission]
|
[Permission]
|
||||||
[ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)]
|
[ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)]
|
||||||
public async Task<IActionResult> DeleteRowAsync(int idWell, int idRow, CancellationToken token = default)
|
public async Task<IActionResult> DeleteAsync(int idWell, int idRow, CancellationToken token = default)
|
||||||
{
|
{
|
||||||
if (!await CanUserAccessToWellAsync(idWell,
|
if (!await CanUserAccessToWellAsync(idWell,
|
||||||
token).ConfigureAwait(false))
|
token).ConfigureAwait(false))
|
||||||
|
Loading…
Reference in New Issue
Block a user