Fix mapping entity to dto

This commit is contained in:
Степанов Дмитрий 2024-02-21 09:48:13 +03:00
parent 615771395d
commit ac21fc6776

View File

@ -60,7 +60,8 @@ public class DetectedOperationRepository : CrudRepositoryBase<DetectedOperationD
var query = BuildQuery(request)
.Include(o => o.OperationCategory);
var entities = await query.ToArrayAsync(token);
var dtos = entities.Select(Convert);
var offset = telemetryService.GetTimezone(request.IdTelemetry).Offset;
var dtos = entities.Select(o => Convert(o, offset));
return dtos;
}
@ -181,13 +182,11 @@ public class DetectedOperationRepository : CrudRepositoryBase<DetectedOperationD
return query;
}
protected override DetectedOperationDto Convert(DetectedOperation src)
protected virtual DetectedOperationDto Convert(DetectedOperation src, TimeSpan offset)
{
var timezone = telemetryService.GetTimezone(src.IdTelemetry);
var dto = src.Adapt<DetectedOperationDto>();
dto.DateStart = src.DateStart.ToOffset(timezone.Offset);
dto.DateEnd = src.DateEnd.ToOffset(timezone.Offset);
dto.DateStart = src.DateStart.ToOffset(offset);
dto.DateEnd = src.DateEnd.ToOffset(offset);
return dto;
}