using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using AsbCloudApp.Data;
using AsbCloudApp.Repositories;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
namespace AsbCloudWebApi.Controllers;
///
/// Секции скважины
///
[Authorize]
[ApiController]
[Route("api/[controller]")]
public class WellSectionsController : ControllerBase
{
private readonly IWellOperationRepository wellOperationRepository;
public WellSectionsController(IWellOperationRepository wellOperationRepository)
{
this.wellOperationRepository = wellOperationRepository;
}
///
/// Получение списка плановых секций скважин
///
/// Идентификаторы скважин
///
///
[HttpGet("plan")]
[ProducesResponseType(typeof(IEnumerable), StatusCodes.Status200OK)]
public async Task GetPlanAsync([FromQuery] IEnumerable idsWells,
CancellationToken cancellationToken)
{
var sections = await wellOperationRepository.GetSectionsAsync(idsWells, cancellationToken);
sections = sections.Where(section => section.IdType == 0);
return Ok(sections);
}
///
/// Получение списка фактических секций скважин
///
/// Идентификаторы скважин
///
///
[HttpGet("fact")]
[ProducesResponseType(typeof(IEnumerable), StatusCodes.Status200OK)]
public async Task GetFactAsync([FromQuery] IEnumerable idsWells,
CancellationToken cancellationToken)
{
var sections = await wellOperationRepository.GetSectionsAsync(idsWells, cancellationToken);
sections = sections.Where(section => section.IdType == 1);
return Ok(sections);
}
}