DD.WellWorkover.Cloud/AsbCloudWebApi/Controllers/DepositController.cs

90 lines
3.2 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using AsbCloudApp.Data;
using AsbCloudApp.Repositories;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
namespace AsbCloudWebApi.Controllers
{
/// <summary>
/// Инфо о месторождениях
/// </summary>
[Route("api/deposit")]
[ApiController]
[Authorize]
public class DepositController : ControllerBase
{
private readonly IDepositRepository depositService;
public DepositController(IDepositRepository depositService)
{
this.depositService = depositService;
}
/// <summary>
/// Получает список доступных пользователю месторождений
/// </summary>
/// <param name="token"> Токен отмены задачи </param>
/// <returns></returns>
[HttpGet]
[Permission]
[ProducesResponseType(typeof(IEnumerable<DepositDto>), (int)System.Net.HttpStatusCode.OK)]
public async Task<IActionResult> GetDepositsAsync(CancellationToken token)
{
int? idCompany = User.GetCompanyId();
if (idCompany is null)
return Forbid();
var result = await depositService.GetAsync((int)idCompany,
token).ConfigureAwait(false);
return Ok(result);
}
/// <summary>
/// Получает список доступных пользователю месторождений (только скважины с параметрами бурения)
/// </summary>
/// <param name="token"> Токен отмены задачи </param>
/// <returns></returns>
[HttpGet("drillParamsWells")]
[Permission]
[ProducesResponseType(typeof(IEnumerable<DepositDto>), (int)System.Net.HttpStatusCode.OK)]
public async Task<IActionResult> GetDepositsDrillParamsAsync(CancellationToken token)
{
int? idCompany = User.GetCompanyId();
if (idCompany is null)
return Forbid();
var result = await depositService.GetAllWithDrillParamsAsync((int)idCompany,
token).ConfigureAwait(false);
return Ok(result);
}
/// <summary>
/// Получает список доступных пользователю кустов месторождения
/// </summary>
/// <param name="depositId"></param>
/// <param name="token"> Токен отмены задачи </param>
/// <returns></returns>
[HttpGet("{depositId}")]
[Permission]
[ProducesResponseType(typeof(IEnumerable<ClusterDto>), (int)System.Net.HttpStatusCode.OK)]
public async Task<IActionResult> GetClustersAsync(int depositId,
CancellationToken token)
{
int? idCompany = User.GetCompanyId();
if (idCompany is null)
return Forbid();
var result = await depositService.GetClustersAsync((int)idCompany,
depositId, token).ConfigureAwait(false);
return Ok(result);
}
}
}