forked from ddrilling/AsbCloudServer
Рефактор: метод записи ключа пользоватеоя, редактирующего рапорт
This commit is contained in:
parent
baee2ae139
commit
7997639e6c
@ -91,11 +91,9 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
[ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)]
|
[ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)]
|
||||||
public async Task<IActionResult> UpdateHeadAsync(int idWell, [Required] DateTime date, [Required] HeadDto dto, CancellationToken token = default)
|
public async Task<IActionResult> UpdateHeadAsync(int idWell, [Required] DateTime date, [Required] HeadDto dto, CancellationToken token = default)
|
||||||
{
|
{
|
||||||
var idUser = User.GetUserId();
|
if (!setEditorIdToDailyReportBlock(dto))
|
||||||
if (idUser is null)
|
|
||||||
return Forbid();
|
return Forbid();
|
||||||
|
|
||||||
dto.IdUser = idUser;
|
|
||||||
var result = await dailyReportService.UpdateBlockAsync(idWell, date, dto, token);
|
var result = await dailyReportService.UpdateBlockAsync(idWell, date, dto, token);
|
||||||
return Ok(result);
|
return Ok(result);
|
||||||
}
|
}
|
||||||
@ -112,11 +110,9 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
[ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)]
|
[ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)]
|
||||||
public async Task<IActionResult> UpdateBhaAsync(int idWell, [Required] DateTime date, [Required] BhaDto dto, CancellationToken token = default)
|
public async Task<IActionResult> UpdateBhaAsync(int idWell, [Required] DateTime date, [Required] BhaDto dto, CancellationToken token = default)
|
||||||
{
|
{
|
||||||
var idUser = User.GetUserId();
|
if (!setEditorIdToDailyReportBlock(dto))
|
||||||
if (idUser is null)
|
|
||||||
return Forbid();
|
return Forbid();
|
||||||
|
|
||||||
dto.IdUser = idUser;
|
|
||||||
var result = await dailyReportService.UpdateBlockAsync(idWell, date, dto, token);
|
var result = await dailyReportService.UpdateBlockAsync(idWell, date, dto, token);
|
||||||
return Ok(result);
|
return Ok(result);
|
||||||
}
|
}
|
||||||
@ -133,16 +129,13 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
[ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)]
|
[ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)]
|
||||||
public async Task<IActionResult> UpdateNoDrillingAsync(int idWell, [Required] DateTime date, [Required] NoDrillingDto dto, CancellationToken token = default)
|
public async Task<IActionResult> UpdateNoDrillingAsync(int idWell, [Required] DateTime date, [Required] NoDrillingDto dto, CancellationToken token = default)
|
||||||
{
|
{
|
||||||
var idUser = User.GetUserId();
|
if (!setEditorIdToDailyReportBlock(dto))
|
||||||
if (idUser is null)
|
|
||||||
return Forbid();
|
return Forbid();
|
||||||
|
|
||||||
dto.IdUser = idUser;
|
|
||||||
var result = await dailyReportService.UpdateBlockAsync(idWell, date, dto, token);
|
var result = await dailyReportService.UpdateBlockAsync(idWell, date, dto, token);
|
||||||
return Ok(result);
|
return Ok(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Сохранение изменений набора данных для формирования рапорта (САУБ)
|
/// Сохранение изменений набора данных для формирования рапорта (САУБ)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -155,11 +148,9 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
[ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)]
|
[ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)]
|
||||||
public async Task<IActionResult> UpdateSaubAsync(int idWell, [Required] DateTime date, [Required] SaubDto dto, CancellationToken token = default)
|
public async Task<IActionResult> UpdateSaubAsync(int idWell, [Required] DateTime date, [Required] SaubDto dto, CancellationToken token = default)
|
||||||
{
|
{
|
||||||
var idUser = User.GetUserId();
|
if (!setEditorIdToDailyReportBlock(dto))
|
||||||
if (idUser is null)
|
|
||||||
return Forbid();
|
return Forbid();
|
||||||
|
|
||||||
dto.IdUser = idUser;
|
|
||||||
var result = await dailyReportService.UpdateBlockAsync(idWell, date, dto, token);
|
var result = await dailyReportService.UpdateBlockAsync(idWell, date, dto, token);
|
||||||
return Ok(result);
|
return Ok(result);
|
||||||
}
|
}
|
||||||
@ -176,15 +167,29 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
[ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)]
|
[ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)]
|
||||||
public async Task<IActionResult> UpdateSignAsync(int idWell, [Required] DateTime date, [Required] SignDto dto, CancellationToken token = default)
|
public async Task<IActionResult> UpdateSignAsync(int idWell, [Required] DateTime date, [Required] SignDto dto, CancellationToken token = default)
|
||||||
{
|
{
|
||||||
var idUser = User.GetUserId();
|
if (!setEditorIdToDailyReportBlock(dto))
|
||||||
if (idUser is null)
|
|
||||||
return Forbid();
|
return Forbid();
|
||||||
|
|
||||||
dto.IdUser = idUser;
|
|
||||||
var result = await dailyReportService.UpdateBlockAsync(idWell, date, dto, token);
|
var result = await dailyReportService.UpdateBlockAsync(idWell, date, dto, token);
|
||||||
return Ok(result);
|
return Ok(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// записать ключ пользователя, вносящего изменения в блок суточного рапорта
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="dto"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
private bool setEditorIdToDailyReportBlock(ItemInfoDto dto)
|
||||||
|
{
|
||||||
|
var idUser = User.GetUserId();
|
||||||
|
if (idUser is null)
|
||||||
|
return false;
|
||||||
|
else
|
||||||
|
dto.IdUser = idUser;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Сформировать и скачать рапорт в формате excel
|
/// Сформировать и скачать рапорт в формате excel
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
Loading…
Reference in New Issue
Block a user