diff --git a/Persistence.API/Controllers/ChangeLogController.cs b/Persistence.API/Controllers/ChangeLogController.cs index 54a3b0c..cad59c4 100644 --- a/Persistence.API/Controllers/ChangeLogController.cs +++ b/Persistence.API/Controllers/ChangeLogController.cs @@ -37,7 +37,7 @@ public class ChangeLogController : ControllerBase, IChangeLogApi public async Task AddRange( [FromRoute] Guid idDiscriminator, [FromBody] IEnumerable dtos, - CancellationToken token = default) + CancellationToken token) { var userId = User.GetUserId(); var result = await repository.AddRange(userId, idDiscriminator, dtos, token); @@ -47,7 +47,7 @@ public class ChangeLogController : ControllerBase, IChangeLogApi [HttpDelete] [ProducesResponseType(typeof(int), (int)HttpStatusCode.OK)] - public async Task Delete(Guid id, CancellationToken token = default) + public async Task Delete(Guid id, CancellationToken token) { var userId = User.GetUserId(); var result = await repository.MarkAsDeleted(userId, [id], token); @@ -57,7 +57,7 @@ public class ChangeLogController : ControllerBase, IChangeLogApi [HttpDelete("range")] [ProducesResponseType(typeof(int), (int)HttpStatusCode.OK)] - public async Task DeleteRange(IEnumerable ids, CancellationToken token = default) + public async Task DeleteRange(IEnumerable ids, CancellationToken token) { var userId = User.GetUserId(); var result = await repository.MarkAsDeleted(userId, ids, token); @@ -70,7 +70,7 @@ public class ChangeLogController : ControllerBase, IChangeLogApi public async Task ClearAndAddRange( [FromRoute] Guid idDiscriminator, [FromBody] IEnumerable dtos, - CancellationToken token = default) + CancellationToken token) { var userId = User.GetUserId(); var result = await repository.ClearAndAddRange(userId, idDiscriminator, dtos, token); @@ -81,7 +81,7 @@ public class ChangeLogController : ControllerBase, IChangeLogApi [ProducesResponseType(typeof(int), (int)HttpStatusCode.OK)] public async Task Update( DataWithWellDepthAndSectionDto dto, - CancellationToken token = default) + CancellationToken token) { var userId = User.GetUserId(); var result = await repository.UpdateRange(userId, [dto], token); @@ -93,7 +93,7 @@ public class ChangeLogController : ControllerBase, IChangeLogApi [ProducesResponseType(typeof(int), (int)HttpStatusCode.OK)] public async Task UpdateRange( IEnumerable dtos, - CancellationToken token = default) + CancellationToken token) { var userId = User.GetUserId(); var result = await repository.UpdateRange(userId, dtos, token); @@ -107,7 +107,7 @@ public class ChangeLogController : ControllerBase, IChangeLogApi [FromRoute] Guid idDiscriminator, [FromQuery] SectionPartRequest filterRequest, [FromQuery] PaginationRequest paginationRequest, - CancellationToken token = default) + CancellationToken token) { var moment = new DateTimeOffset(3000, 1, 1, 0, 0, 0, TimeSpan.Zero); var result = await repository.GetByDate(idDiscriminator, moment, filterRequest, paginationRequest, token); @@ -122,7 +122,7 @@ public class ChangeLogController : ControllerBase, IChangeLogApi DateTimeOffset moment, [FromQuery] SectionPartRequest filterRequest, [FromQuery] PaginationRequest paginationRequest, - CancellationToken token = default) + CancellationToken token) { var result = await repository.GetByDate(idDiscriminator, moment, filterRequest, paginationRequest, token); @@ -131,11 +131,12 @@ public class ChangeLogController : ControllerBase, IChangeLogApi [HttpGet("history/{idDiscriminator}")] [ProducesResponseType(typeof(IEnumerable), (int)HttpStatusCode.OK)] + [ProducesResponseType((int)HttpStatusCode.NoContent)] public async Task GetChangeLogForDate( [FromRoute] Guid idDiscriminator, DateTimeOffset dateBegin, DateTimeOffset dateEnd, - CancellationToken token = default) + CancellationToken token) { var result = await repository.GetChangeLogForInterval(idDiscriminator, dateBegin, dateEnd, token); @@ -144,7 +145,8 @@ public class ChangeLogController : ControllerBase, IChangeLogApi [HttpGet("datesChange/{idDiscriminator}")] [ProducesResponseType(typeof(IEnumerable), (int)HttpStatusCode.OK)] - public async Task GetDatesChange([FromRoute] Guid idDiscriminator, CancellationToken token = default) + [ProducesResponseType((int)HttpStatusCode.NoContent)] + public async Task GetDatesChange([FromRoute] Guid idDiscriminator, CancellationToken token) { var result = await repository.GetDatesChange(idDiscriminator, token); @@ -153,6 +155,7 @@ public class ChangeLogController : ControllerBase, IChangeLogApi [HttpGet("part/{idDiscriminator}")] [ProducesResponseType(typeof(IEnumerable), (int)HttpStatusCode.OK)] + [ProducesResponseType((int)HttpStatusCode.NoContent)] public async Task GetPart([FromRoute] Guid idDiscriminator, DateTimeOffset dateBegin, int take = 86400, CancellationToken token = default) { var result = await repository.GetGtDate(idDiscriminator, dateBegin, token); @@ -163,7 +166,7 @@ public class ChangeLogController : ControllerBase, IChangeLogApi [HttpGet("datesRange/{idDiscriminator}")] [ProducesResponseType(typeof(DatesRangeDto), (int)HttpStatusCode.OK)] [ProducesResponseType((int)HttpStatusCode.NoContent)] - public async Task GetDatesRangeAsync([FromRoute] Guid idDiscriminator, CancellationToken token = default) + public async Task GetDatesRangeAsync([FromRoute] Guid idDiscriminator, CancellationToken token) { var result = await repository.GetDatesRange(idDiscriminator, token); diff --git a/Persistence.Repository/QueryBuilders.cs b/Persistence.Repository/QueryBuilders.cs index 9ed98e5..6070a8a 100644 --- a/Persistence.Repository/QueryBuilders.cs +++ b/Persistence.Repository/QueryBuilders.cs @@ -67,12 +67,14 @@ public static class QueryBuilders .Take(request.Take) .ToArrayAsync(token); + var count = await query.CountAsync(token); + var items = entities.Select(Convert); var result = new PaginationContainer { Skip = request.Skip, Take = request.Take, - Items = entities.Select(Convert), - Count = await query.CountAsync(token) + Items = items, + Count = count }; return result;