featute/ChangeLog #6

Merged
on.nemtina merged 25 commits from featute/ChangeLog into master 2024-12-09 17:44:48 +05:00
3 changed files with 11 additions and 12 deletions
Showing only changes of commit e826a386d2 - Show all commits

View File

@ -66,20 +66,18 @@ public interface IChangeLogClient
/// <summary> /// <summary>
/// Обновить одну запись /// Обновить одну запись
/// </summary> /// </summary>
/// <param name="idDiscriminator"></param>
/// <param name="dto"></param> /// <param name="dto"></param>
/// <returns></returns> /// <returns></returns>
[Put($"{BaseRoute}/{{idDiscriminator}}")] [Put($"{BaseRoute}")]
Task<IApiResponse<int>> Update(Guid idDiscriminator, DataWithWellDepthAndSectionDto dto); Task<IApiResponse<int>> Update(DataWithWellDepthAndSectionDto dto);
/// <summary> /// <summary>
/// Обновить несколько записей /// Обновить несколько записей
/// </summary> /// </summary>
/// <param name="idDiscriminator"></param>
/// <param name="dtos"></param> /// <param name="dtos"></param>
/// <returns></returns> /// <returns></returns>
[Put($"{BaseRoute}/range/{{idDiscriminator}}")] [Put($"{BaseRoute}/range")]
Task<IApiResponse<int>> UpdateRange(Guid idDiscriminator, IEnumerable<DataWithWellDepthAndSectionDto> dtos); Task<IApiResponse<int>> UpdateRange(IEnumerable<DataWithWellDepthAndSectionDto> dtos);
/// <summary> /// <summary>
/// Удалить одну запись /// Удалить одну запись
@ -102,7 +100,7 @@ public interface IChangeLogClient
/// </summary> /// </summary>
/// <param name="idDiscriminator"></param> /// <param name="idDiscriminator"></param>
/// <returns></returns> /// <returns></returns>
[Get($"{BaseRoute}/datesRange")] [Get($"{BaseRoute}/datesRange/{{idDiscriminator}}")]
Task<IApiResponse<DatesRangeDto?>> GetDatesRange(Guid idDiscriminator); Task<IApiResponse<DatesRangeDto?>> GetDatesRange(Guid idDiscriminator);
} }

View File

@ -105,7 +105,7 @@ public class ChangeLogControllerTest : BaseIntegrationTest
dto.DepthEnd = dto.DepthEnd + 10; dto.DepthEnd = dto.DepthEnd + 10;
// act // act
result = await client.Update(idDiscriminator, dto); result = await client.Update(dto);
// assert // assert
Assert.Equal(HttpStatusCode.OK, result.StatusCode); Assert.Equal(HttpStatusCode.OK, result.StatusCode);
@ -143,7 +143,6 @@ public class ChangeLogControllerTest : BaseIntegrationTest
{ {
// arrange // arrange
var count = 2; var count = 2;
var idDiscriminator = Guid.NewGuid();
var dtos = Generate(count, DateTimeOffset.UtcNow); var dtos = Generate(count, DateTimeOffset.UtcNow);
var entities = dtos.Select(d => d.Adapt<ChangeLog>()).ToArray(); var entities = dtos.Select(d => d.Adapt<ChangeLog>()).ToArray();
dbContext.ChangeLog.AddRange(entities); dbContext.ChangeLog.AddRange(entities);
@ -159,7 +158,7 @@ public class ChangeLogControllerTest : BaseIntegrationTest
}).ToArray(); }).ToArray();
// act // act
var result = await client.UpdateRange(idDiscriminator, dtos); var result = await client.UpdateRange(dtos);
// assert // assert
Assert.Equal(HttpStatusCode.OK, result.StatusCode); Assert.Equal(HttpStatusCode.OK, result.StatusCode);
@ -298,7 +297,7 @@ public class ChangeLogControllerTest : BaseIntegrationTest
entity.DepthEnd = entity.DepthEnd + 10; entity.DepthEnd = entity.DepthEnd + 10;
} }
var dtos = entities.Select(e => e.Adapt<DataWithWellDepthAndSectionDto>()).ToArray(); var dtos = entities.Select(e => e.Adapt<DataWithWellDepthAndSectionDto>()).ToArray();
await client.UpdateRange(idDiscriminator, dtos); await client.UpdateRange(dtos);
//act //act
var dateBegin = DateTimeOffset.UtcNow.AddDays(daysBeforeNowFilter); var dateBegin = DateTimeOffset.UtcNow.AddDays(daysBeforeNowFilter);

View File

@ -241,7 +241,9 @@ public class ChangeLogRepository : IChangeLogRepository
.Select(group => new .Select(group => new
{ {
Min = group.Min(e => e.Creation), Min = group.Min(e => e.Creation),
Max = group.Max(e => (e.Creation > e.Obsolete ? e.Creation : e.Obsolete!.Value)), Max = group.Max(e => (e.Obsolete.HasValue && e.Obsolete > e.Creation)
? e.Obsolete.Value
: e.Creation),
}); });
var values = await query.FirstOrDefaultAsync(token); var values = await query.FirstOrDefaultAsync(token);