forked from ddrilling/AsbCloudServer
Merge pull request 'Пакетное удаление операций по скважине' (#277) from fix/well-operations-delete-range into dev
Reviewed-on: http://test.digitaldrilling.ru:8080/DDrilling/AsbCloudServer/pulls/277
This commit is contained in:
commit
7add70a280
@ -16,6 +16,7 @@ using AsbCloudApp.Requests.ExportOptions;
|
|||||||
using AsbCloudApp.Requests.ParserOptions;
|
using AsbCloudApp.Requests.ParserOptions;
|
||||||
using AsbCloudDb.Model;
|
using AsbCloudDb.Model;
|
||||||
using AsbCloudInfrastructure.Services.WellOperations.Factories;
|
using AsbCloudInfrastructure.Services.WellOperations.Factories;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace AsbCloudWebApi.Controllers;
|
namespace AsbCloudWebApi.Controllers;
|
||||||
|
|
||||||
@ -250,6 +251,35 @@ public class WellOperationController : ControllerBase
|
|||||||
return Ok(result);
|
return Ok(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Удаляет выбранные операции по скважине
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="idWell">id скважины</param>
|
||||||
|
/// <param name="ids">ids выбранных операций</param>
|
||||||
|
/// <param name="token">Токен отмены задачи</param>
|
||||||
|
/// <returns>Количество удаленных из БД строк</returns>
|
||||||
|
[HttpDelete]
|
||||||
|
[ProducesResponseType(typeof(int), StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
|
||||||
|
public async Task<IActionResult> DeleteRangeAsync([FromRoute] int idWell, IEnumerable<int> ids, CancellationToken token)
|
||||||
|
{
|
||||||
|
if (!await CanUserAccessToWellAsync(idWell, token))
|
||||||
|
return Forbid();
|
||||||
|
|
||||||
|
if (!await CanUserEditWellOperationsAsync(idWell, token))
|
||||||
|
return Forbid();
|
||||||
|
|
||||||
|
if (!ids.Any())
|
||||||
|
return this.ValidationBadRequest(nameof(ids), "Пустой список операций");
|
||||||
|
|
||||||
|
var result = await wellOperationRepository.DeleteRangeAsync(ids, token);
|
||||||
|
|
||||||
|
if(result == ICrudRepository<WellOperationDto>.ErrorIdNotFound)
|
||||||
|
return this.ValidationBadRequest(nameof(ids), "Минимум одна из операций не найдена в базе");
|
||||||
|
|
||||||
|
return Ok(result);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Формирование excel файла с операциями на скважине
|
/// Формирование excel файла с операциями на скважине
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
Loading…
Reference in New Issue
Block a user