forked from ddrilling/AsbCloudServer
62 lines
1.6 KiB
C#
62 lines
1.6 KiB
C#
using AsbCloudApp.Data;
|
|
using AsbCloudApp.Services;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
namespace AsbCloudWebApi.Controllers
|
|
{
|
|
[Route("api/well")]
|
|
[ApiController]
|
|
[Authorize]
|
|
public class WellController : ControllerBase
|
|
{
|
|
private readonly IWellService wellService;
|
|
|
|
public WellController(IWellService wellService)
|
|
{
|
|
this.wellService = wellService;
|
|
}
|
|
|
|
[HttpGet]
|
|
[ProducesResponseType(typeof(IEnumerable<WellDto>), (int)System.Net.HttpStatusCode.OK)]
|
|
public IActionResult GetWells()
|
|
{
|
|
var idCompany = User.GetCompanyId();
|
|
|
|
if (idCompany is null)
|
|
{
|
|
return NoContent();
|
|
}
|
|
|
|
var wells = wellService.GetWellsByCompany((int)idCompany);
|
|
|
|
if (wells is null || !wells.Any())
|
|
return NoContent();
|
|
|
|
return Ok(wells);
|
|
}
|
|
|
|
[HttpGet("transmittingWells")]
|
|
[ProducesResponseType(typeof(IEnumerable<WellDto>), (int)System.Net.HttpStatusCode.OK)]
|
|
public IActionResult GetTransmittingWells()
|
|
{
|
|
var idCompany = User.GetCompanyId();
|
|
|
|
if (idCompany is null)
|
|
{
|
|
return NoContent();
|
|
}
|
|
|
|
var transmittingWells = wellService.GetTransmittingWells((int)idCompany);
|
|
|
|
if (transmittingWells is null || !transmittingWells.Any())
|
|
return NoContent();
|
|
|
|
return Ok(transmittingWells);
|
|
|
|
}
|
|
}
|
|
}
|