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 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 Insert([FromBody] WellSectionDto value, CancellationToken token = default) { var result = await service.InsertAsync(value, token).ConfigureAwait(false); return Ok(result); } [HttpPut("{id}")] public async Task 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 Delete(int id, CancellationToken token = default) { var result = await service.DeleteAsync(id, token).ConfigureAwait(false); return Ok(result); } } }