DD.WellWorkover.Cloud/AsbCloudWebApi/Controllers/DepositController.cs
2021-07-21 15:29:19 +05:00

61 lines
1.8 KiB
C#

using AsbCloudApp.Data;
using AsbCloudApp.Services;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
namespace AsbCloudWebApi.Controllers
{
/// <summary>
/// Контроллер для месторождений
/// </summary>
[Route("api/deposit")]
[ApiController]
[Authorize]
public class DepositController : ControllerBase
{
IClusterService clusterService;
public DepositController(IClusterService clusterService)
{
this.clusterService = clusterService;
}
/// <summary>
/// Получает список доступных пользователю месторождений
/// </summary>
/// <returns></returns>
[HttpGet]
[ProducesResponseType(typeof(IEnumerable<DepositDto>), (int)System.Net.HttpStatusCode.OK)]
public IActionResult GetDeposits()
{
int? idCompany = User.GetCompanyId();
if (idCompany is null)
return Forbid();
var result = clusterService.GetDeposits((int)idCompany);
return Ok(result);
}
/// <summary>
/// Получает список доступных пользователю кустов месторождения
/// </summary>
/// <param name="depositId"></param>
/// <returns></returns>
[HttpGet("{depositId}")]
[ProducesResponseType(typeof(IEnumerable<ClusterDto>), (int)System.Net.HttpStatusCode.OK)]
public IActionResult GetClusters(int depositId)
{
int? idCompany = User.GetCompanyId();
if (idCompany is null)
return Forbid();
var result = clusterService.GetClusters((int)idCompany, depositId);
return Ok(result);
}
}
}