diff --git a/AsbCloudApp/Services/IWellSectionService.cs b/AsbCloudApp/Services/IWellSectionService.cs index 02cd3880..4e854d84 100644 --- a/AsbCloudApp/Services/IWellSectionService.cs +++ b/AsbCloudApp/Services/IWellSectionService.cs @@ -10,8 +10,8 @@ namespace AsbCloudApp.Services Task> GetAllByWellIdAsync(int idWell, int skip = 0, int take = 32, CancellationToken token = default); Task GetAsync(int id, CancellationToken token = default); Task InsertAsync(WellSectionDto newItem, int idWell, CancellationToken token = default); - Task> InsertRangeAsync(IEnumerable newItems, int idWell, CancellationToken token = default); - Task UpdateAsync(WellSectionDto item, int idSection, int idWell, CancellationToken token = default); + Task> InsertRangeAsync(int idWell, IEnumerable newItems, CancellationToken token = default); + Task UpdateAsync(int idWell, int idSection, WellSectionDto item, CancellationToken token = default); Task DeleteAsync(IEnumerable ids, CancellationToken token = default); } } diff --git a/AsbCloudInfrastructure/Services/WellSectionService.cs b/AsbCloudInfrastructure/Services/WellSectionService.cs index b78447fb..e5c8d90d 100644 --- a/AsbCloudInfrastructure/Services/WellSectionService.cs +++ b/AsbCloudInfrastructure/Services/WellSectionService.cs @@ -90,7 +90,7 @@ namespace AsbCloudInfrastructure.Services return dto; } - public async Task> InsertRangeAsync(IEnumerable items, int idWell, CancellationToken token = default) + public async Task> InsertRangeAsync(int idWell, IEnumerable items, CancellationToken token = default) { var dbEntities = new Microsoft.EntityFrameworkCore.ChangeTracking.EntityEntry[items.Count()]; @@ -115,7 +115,7 @@ namespace AsbCloudInfrastructure.Services return dtos; } - public async Task UpdateAsync(WellSectionDto item, int idSection, int idWell, CancellationToken token = default) + public async Task UpdateAsync(int idWell, int idSection, WellSectionDto item, CancellationToken token = default) { var sectionType = await GetWellSectionTypeFromCacheAndAssert(item.SectionType); diff --git a/AsbCloudWebApi/Controllers/WellSectionController.cs b/AsbCloudWebApi/Controllers/WellSectionController.cs index bb13d194..4817cb83 100644 --- a/AsbCloudWebApi/Controllers/WellSectionController.cs +++ b/AsbCloudWebApi/Controllers/WellSectionController.cs @@ -35,7 +35,7 @@ namespace AsbCloudWebApi.Controllers [HttpGet] [Route("{idSection}")] - public async Task GetAsync(int idSection, int idWell, + public async Task GetAsync(int idWell, int idSection, CancellationToken token = default) { if (!await CanUserAccessToWellAsync(idWell, token)) @@ -52,27 +52,27 @@ namespace AsbCloudWebApi.Controllers if (!await CanUserAccessToWellAsync(idWell, token)) return Forbid(); - var result = await sectionsService.InsertRangeAsync(values, idWell, token).ConfigureAwait(false); + var result = await sectionsService.InsertRangeAsync(idWell, values, token).ConfigureAwait(false); return Ok(result); } - [HttpPut("{id}")] - public async Task PutAsync(int id, int idWell, [FromBody] WellSectionDto value, CancellationToken token = default) + [HttpPut("{idSection}")] + public async Task UpdateAsync(int idWell, int idSection, [FromBody] WellSectionDto value, CancellationToken token = default) { if (!await CanUserAccessToWellAsync(idWell, token)) return Forbid(); - var result = await sectionsService.UpdateAsync(value, id, idWell, token).ConfigureAwait(false); + var result = await sectionsService.UpdateAsync(idWell, idSection, value, token).ConfigureAwait(false); return Ok(result); } - [HttpDelete("{id}")] - public async Task DeleteAsync(int id, int idWell, CancellationToken token = default) + [HttpDelete("{idSection}")] + public async Task DeleteAsync(int idWell, int idSection, CancellationToken token = default) { if (!await CanUserAccessToWellAsync(idWell, token)) return Forbid(); - var result = await sectionsService.DeleteAsync(new int[] { id }, token).ConfigureAwait(false); + var result = await sectionsService.DeleteAsync(new int[] { idSection }, token).ConfigureAwait(false); return Ok(result); }