DD.WellWorkover.Cloud/AsbCloudWebApi/Controllers/WellSectionController.cs

52 lines
1.7 KiB
C#
Raw Normal View History

2021-08-02 14:45:13 +05:00
using AsbCloudApp.Data;
using AsbCloudApp.Services;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
2021-08-10 14:36:35 +05:00
using System.Threading;
using System.Threading.Tasks;
2021-08-02 14:45:13 +05:00
namespace AsbCloudWebApi.Controllers
{
2021-08-10 14:36:35 +05:00
[Route("api/well/{idWell}/sections")]
2021-08-02 14:45:13 +05:00
[ApiController]
[Authorize]
2021-08-10 14:36:35 +05:00
public class WellSectionController : ControllerBase
2021-08-02 14:45:13 +05:00
{
2021-08-10 14:36:35 +05:00
private readonly IWellSectionService service;
2021-08-02 14:45:13 +05:00
2021-08-10 14:36:35 +05:00
public WellSectionController(IWellSectionService service)
{
this.service = service;
2021-08-02 14:45:13 +05:00
}
[HttpGet]
[Route("")]
2021-08-10 14:36:35 +05:00
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)
2021-08-02 14:45:13 +05:00
{
2021-08-10 14:36:35 +05:00
var result = await service.DeleteAsync(id, token).ConfigureAwait(false);
2021-08-02 14:45:13 +05:00
return Ok(result);
}
}
}