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? idCustomer = User.GetCustomerId(); if (idCustomer is null) return Forbid(); var result = clusterService.GetDeposits((int)idCustomer); return Ok(result); } /// /// Получает список доступных пользователю кустов месторождения /// /// /// [HttpGet("{depositId}")] [ProducesResponseType(typeof(IEnumerable), (int)System.Net.HttpStatusCode.OK)] public IActionResult GetClusters(int depositId) { int? idCustomer = User.GetCustomerId(); if (idCustomer is null) return Forbid(); var result = clusterService.GetClusters((int)idCustomer, depositId); return Ok(result); } } }