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/[controller]")]
[ApiController]
[Authorize]
public class ClusterController : ControllerBase
{
private readonly IClusterService clusterService;
public ClusterController(IClusterService clusterService)
{
this.clusterService = clusterService;
}
///
/// Получение доступных пользователю скважин
///
///
///
[HttpGet("{clusterId}")]
[ProducesResponseType(typeof(IEnumerable), (int)System.Net.HttpStatusCode.OK)]
public IActionResult GetWells(int clusterId)
{
int? idCustomer = User.GetCustomerId();
if (idCustomer is null)
return Forbid();
var result = clusterService.GetWells((int)idCustomer, clusterId);
return Ok(result);
}
///
/// Получение обопщенной аналитики по кусту (лучшая/худшая скважина)
///
///
///
[HttpGet("{clusterId}/Analysis")]
[ProducesResponseType(typeof(IEnumerable), (int)System.Net.HttpStatusCode.OK)]
public IActionResult GetAnalysis(int clusterId)
{
int? idCustomer = User.GetCustomerId();
if (idCustomer is null)
return Forbid();
var result = clusterService.GetAnalysis((int)idCustomer, clusterId);
return Ok(result);
}
}
}