forked from ddrilling/AsbCloudServer
Merge branch 'dev' of https://bitbucket.org/autodrilling/asbcloudserver into dev
This commit is contained in:
commit
aab6064153
11
AsbCloudApp/Data/WellUpdateDto.cs
Normal file
11
AsbCloudApp/Data/WellUpdateDto.cs
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
namespace AsbCloudApp.Data
|
||||||
|
{
|
||||||
|
public class WellUpdateParamsDto
|
||||||
|
{
|
||||||
|
public string Caption { get; set; }
|
||||||
|
public double? Latitude { get; set; }
|
||||||
|
public double? Longitude { get; set; }
|
||||||
|
public int IdWellType { get; set; }
|
||||||
|
public int State { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -8,9 +8,7 @@ namespace AsbCloudApp.Services
|
|||||||
public interface IWellService
|
public interface IWellService
|
||||||
{
|
{
|
||||||
Task<IEnumerable<WellDto>> GetWellsByCompanyAsync(int idCompany, CancellationToken token);
|
Task<IEnumerable<WellDto>> GetWellsByCompanyAsync(int idCompany, CancellationToken token);
|
||||||
Task<int> UpdateWellAsync(int idWell, string caption = default,
|
Task<int?> UpdateWellAsync(int idWell, WellUpdateParamsDto dto, CancellationToken token = default);
|
||||||
double latitude = default, double longitude = default, int idWellType = default,
|
|
||||||
int state = default, CancellationToken token = default);
|
|
||||||
Task<IEnumerable<WellDto>> GetTransmittingWellsAsync(int idCompany, CancellationToken token);
|
Task<IEnumerable<WellDto>> GetTransmittingWellsAsync(int idCompany, CancellationToken token);
|
||||||
Task<bool> IsCompanyInvolvedInWellAsync(int idCompany, int idWell, CancellationToken token);
|
Task<bool> IsCompanyInvolvedInWellAsync(int idCompany, int idWell, CancellationToken token);
|
||||||
Task<string> GetWellCaptionByIdAsync(int idWell, CancellationToken token);
|
Task<string> GetWellCaptionByIdAsync(int idWell, CancellationToken token);
|
||||||
|
@ -43,33 +43,27 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<int> UpdateWellAsync(int idWell, string caption = default,
|
public async Task<int?> UpdateWellAsync(int idWell, WellUpdateParamsDto dto,
|
||||||
double latitude = default, double longitude = default, int idWellType = default,
|
CancellationToken token = default)
|
||||||
int state = default, CancellationToken token = default)
|
|
||||||
{
|
{
|
||||||
|
if (dto.IdWellType is < 1 or > 2)
|
||||||
|
throw new ArgumentException("Тип секции указан неправильно.");
|
||||||
|
|
||||||
|
if (dto.State is < 0 or > 2)
|
||||||
|
throw new ArgumentException("Текущее состояние работы скважины" +
|
||||||
|
"указано неправильно.");
|
||||||
var well = await db.Wells
|
var well = await db.Wells
|
||||||
.FirstOrDefaultAsync(w => w.Id == idWell, token)
|
.FirstOrDefaultAsync(w => w.Id == idWell, token)
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
|
|
||||||
if (well is null)
|
if (well is null)
|
||||||
return 0;
|
return null;
|
||||||
|
|
||||||
if (caption != default)
|
well.Caption = dto.Caption;
|
||||||
well.Caption = caption;
|
well.Latitude = dto.Latitude;
|
||||||
|
well.Longitude = dto.Longitude;
|
||||||
if (latitude != default)
|
well.IdWellType = dto.IdWellType;
|
||||||
well.Latitude = latitude;
|
well.State = dto.State;
|
||||||
|
|
||||||
if (longitude != default)
|
|
||||||
well.Longitude = longitude;
|
|
||||||
|
|
||||||
if (idWellType != default)
|
|
||||||
well.IdWellType = idWellType;
|
|
||||||
|
|
||||||
if (state < 3)
|
|
||||||
well.State = state;
|
|
||||||
else
|
|
||||||
throw new ArgumentException("Недопустимое значение состояния работы скважины");
|
|
||||||
|
|
||||||
db.Wells.Update(well);
|
db.Wells.Update(well);
|
||||||
|
|
||||||
|
@ -74,18 +74,15 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
/// Редактирует указанные поля скважины
|
/// Редактирует указанные поля скважины
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="idWell"> Id скважины </param>
|
/// <param name="idWell"> Id скважины </param>
|
||||||
/// <param name="caption"> Название скважины </param>
|
/// <param name="dto"> Объект параметров скважины.
|
||||||
/// <param name="latitude"> Широта координат скважины </param>
|
/// IdWellType: 1 - Наклонно-направленная, 2 - Горизонтальная.
|
||||||
/// <param name="longitude"> Долгота координат скважины </param>
|
/// State: 0 - Неизвестно, 1 - В работе, 2 - Завершена.</param>
|
||||||
/// <param name="idWellType"> Id типа скважины </param>
|
|
||||||
/// <param name="state"> Id текущего состояния скважины </param>
|
|
||||||
/// <param name="token"> Токен отмены задачи </param>
|
/// <param name="token"> Токен отмены задачи </param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpPut]
|
[HttpPut]
|
||||||
[ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)]
|
[ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)]
|
||||||
public async Task<IActionResult> UpdateWellAsync(int idWell, string caption = default,
|
public async Task<IActionResult> UpdateWellAsync(int idWell, WellUpdateParamsDto dto,
|
||||||
double latitude = default, double longitude = default, int idWellType = default,
|
CancellationToken token = default)
|
||||||
int state = default, CancellationToken token = default)
|
|
||||||
{
|
{
|
||||||
var idCompany = User.GetCompanyId();
|
var idCompany = User.GetCompanyId();
|
||||||
|
|
||||||
@ -93,8 +90,8 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
idWell, token).ConfigureAwait(false))
|
idWell, token).ConfigureAwait(false))
|
||||||
return Forbid();
|
return Forbid();
|
||||||
|
|
||||||
var result = await wellService.UpdateWellAsync(idWell, caption, latitude, longitude,
|
var result = await wellService.UpdateWellAsync(idWell, dto, token)
|
||||||
idWellType, state, token).ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
|
|
||||||
return Ok(result);
|
return Ok(result);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user