WellSectionController params order

This commit is contained in:
Фролов 2021-08-12 11:50:04 +05:00
parent f0f9d1df73
commit 95a3a0d207
3 changed files with 12 additions and 12 deletions

View File

@ -10,8 +10,8 @@ namespace AsbCloudApp.Services
Task<PaginationContainer<WellSectionDto>> GetAllByWellIdAsync(int idWell, int skip = 0, int take = 32, CancellationToken token = default); Task<PaginationContainer<WellSectionDto>> GetAllByWellIdAsync(int idWell, int skip = 0, int take = 32, CancellationToken token = default);
Task<WellSectionDto> GetAsync(int id, CancellationToken token = default); Task<WellSectionDto> GetAsync(int id, CancellationToken token = default);
Task<WellSectionDto> InsertAsync(WellSectionDto newItem, int idWell, CancellationToken token = default); Task<WellSectionDto> InsertAsync(WellSectionDto newItem, int idWell, CancellationToken token = default);
Task<IEnumerable<WellSectionDto>> InsertRangeAsync(IEnumerable<WellSectionDto> newItems, int idWell, CancellationToken token = default); Task<IEnumerable<WellSectionDto>> InsertRangeAsync(int idWell, IEnumerable<WellSectionDto> newItems, CancellationToken token = default);
Task<WellSectionDto> UpdateAsync(WellSectionDto item, int idSection, int idWell, CancellationToken token = default); Task<WellSectionDto> UpdateAsync(int idWell, int idSection, WellSectionDto item, CancellationToken token = default);
Task<int> DeleteAsync(IEnumerable<int> ids, CancellationToken token = default); Task<int> DeleteAsync(IEnumerable<int> ids, CancellationToken token = default);
} }
} }

View File

@ -90,7 +90,7 @@ namespace AsbCloudInfrastructure.Services
return dto; return dto;
} }
public async Task<IEnumerable<WellSectionDto>> InsertRangeAsync(IEnumerable<WellSectionDto> items, int idWell, CancellationToken token = default) public async Task<IEnumerable<WellSectionDto>> InsertRangeAsync(int idWell, IEnumerable<WellSectionDto> items, CancellationToken token = default)
{ {
var dbEntities = new Microsoft.EntityFrameworkCore.ChangeTracking.EntityEntry<WellSection>[items.Count()]; var dbEntities = new Microsoft.EntityFrameworkCore.ChangeTracking.EntityEntry<WellSection>[items.Count()];
@ -115,7 +115,7 @@ namespace AsbCloudInfrastructure.Services
return dtos; return dtos;
} }
public async Task<WellSectionDto> UpdateAsync(WellSectionDto item, int idSection, int idWell, CancellationToken token = default) public async Task<WellSectionDto> UpdateAsync(int idWell, int idSection, WellSectionDto item, CancellationToken token = default)
{ {
var sectionType = await GetWellSectionTypeFromCacheAndAssert(item.SectionType); var sectionType = await GetWellSectionTypeFromCacheAndAssert(item.SectionType);

View File

@ -35,7 +35,7 @@ namespace AsbCloudWebApi.Controllers
[HttpGet] [HttpGet]
[Route("{idSection}")] [Route("{idSection}")]
public async Task<IActionResult> GetAsync(int idSection, int idWell, public async Task<IActionResult> GetAsync(int idWell, int idSection,
CancellationToken token = default) CancellationToken token = default)
{ {
if (!await CanUserAccessToWellAsync(idWell, token)) if (!await CanUserAccessToWellAsync(idWell, token))
@ -52,27 +52,27 @@ namespace AsbCloudWebApi.Controllers
if (!await CanUserAccessToWellAsync(idWell, token)) if (!await CanUserAccessToWellAsync(idWell, token))
return Forbid(); 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); return Ok(result);
} }
[HttpPut("{id}")] [HttpPut("{idSection}")]
public async Task<IActionResult> PutAsync(int id, int idWell, [FromBody] WellSectionDto value, CancellationToken token = default) public async Task<IActionResult> UpdateAsync(int idWell, int idSection, [FromBody] WellSectionDto value, CancellationToken token = default)
{ {
if (!await CanUserAccessToWellAsync(idWell, token)) if (!await CanUserAccessToWellAsync(idWell, token))
return Forbid(); 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); return Ok(result);
} }
[HttpDelete("{id}")] [HttpDelete("{idSection}")]
public async Task<IActionResult> DeleteAsync(int id, int idWell, CancellationToken token = default) public async Task<IActionResult> DeleteAsync(int idWell, int idSection, CancellationToken token = default)
{ {
if (!await CanUserAccessToWellAsync(idWell, token)) if (!await CanUserAccessToWellAsync(idWell, token))
return Forbid(); 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); return Ok(result);
} }