using AsbCloudApp.Data;
using AsbCloudApp.Services;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace AsbCloudWebApi.Controllers
{
///
/// Контроллер для месторождений
///
[Route("api/deposit")]
[ApiController]
[Authorize]
public class DepositController : ControllerBase
{
IClusterService clusterService;
public DepositController(IClusterService clusterService)
{
this.clusterService = clusterService;
}
///
/// Получает список доступных пользователю месторождений
///
///
[HttpGet]
[ProducesResponseType(typeof(IEnumerable), (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);
}
///
/// Получает список доступных пользователю кустов месторождения
///
///
///
[HttpGet("{depositId}")]
[ProducesResponseType(typeof(IEnumerable), (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);
}
}
}