forked from ddrilling/AsbCloudServer
52 lines
1.7 KiB
C#
52 lines
1.7 KiB
C#
using AsbCloudApp.Data;
|
|
using AsbCloudApp.Services;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace AsbCloudWebApi.Controllers
|
|
{
|
|
[Route("api/well/{idWell}/sections")]
|
|
[ApiController]
|
|
[Authorize]
|
|
public class WellSectionController : ControllerBase
|
|
{
|
|
private readonly IWellSectionService service;
|
|
|
|
public WellSectionController(IWellSectionService service)
|
|
{
|
|
this.service = service;
|
|
}
|
|
|
|
[HttpGet]
|
|
[Route("")]
|
|
public async Task<IActionResult> GetAllAsync(int idWell, int skip = 0, int take = 32, CancellationToken token = default)
|
|
{
|
|
var result = await service.GetAllByWellIdAsync(idWell, skip, take, token).ConfigureAwait(false);
|
|
return Ok(result);
|
|
}
|
|
|
|
[HttpPost]
|
|
public async Task<IActionResult> Insert([FromBody] WellSectionDto value, CancellationToken token = default)
|
|
{
|
|
var result = await service.InsertAsync(value, token).ConfigureAwait(false);
|
|
return Ok(result);
|
|
}
|
|
|
|
[HttpPut("{id}")]
|
|
public async Task<IActionResult> Put(int id, [FromBody] WellSectionDto value, CancellationToken token = default)
|
|
{
|
|
var result = await service.UpdateAsync(value, token).ConfigureAwait(false);
|
|
return Ok(result);
|
|
}
|
|
|
|
[HttpDelete("{id}")]
|
|
public async Task<IActionResult> Delete(int id, CancellationToken token = default)
|
|
{
|
|
var result = await service.DeleteAsync(id, token).ConfigureAwait(false);
|
|
return Ok(result);
|
|
}
|
|
}
|
|
}
|