diff --git a/AsbCloudApp/Data/MeasureDto.cs b/AsbCloudApp/Data/MeasureDto.cs index 9f823a91..4eddd78f 100644 --- a/AsbCloudApp/Data/MeasureDto.cs +++ b/AsbCloudApp/Data/MeasureDto.cs @@ -36,7 +36,7 @@ namespace AsbCloudApp.Data /// отметка времени замера /// [Required] - public DateTime Timestamp { get; set; } + public DateTimeOffset Timestamp { get; set; } /// /// данные замера diff --git a/AsbCloudInfrastructure/Services/MeasureService.cs b/AsbCloudInfrastructure/Services/MeasureService.cs index 58c5c295..7a349450 100644 --- a/AsbCloudInfrastructure/Services/MeasureService.cs +++ b/AsbCloudInfrastructure/Services/MeasureService.cs @@ -87,8 +87,7 @@ namespace AsbCloudInfrastructure.Services throw new ArgumentInvalidException(nameof(dto), "wrong idCategory"); if (!dto.Data.Any()) throw new ArgumentInvalidException(nameof(dto), "data.data is not optional"); - var timezone = wellService.GetTimezone(idWell); - var entity = Convert(dto, timezone.Hours); + var entity = Convert(dto); entity.IdWell = idWell; db.Measures.Add(entity); return db.SaveChangesAsync(token); @@ -110,7 +109,7 @@ namespace AsbCloudInfrastructure.Services var timezone = wellService.GetTimezone(idWell); entity.IdWell = idWell; - entity.Timestamp = dto.Timestamp.ToUtcDateTimeOffset(timezone.Hours); + entity.Timestamp = dto.Timestamp.ToOffset(TimeSpan.FromHours(timezone.Hours)); entity.Data = dto.Data.Adapt(); return await db.SaveChangesAsync(token).ConfigureAwait(false); @@ -142,13 +141,13 @@ namespace AsbCloudInfrastructure.Services { var dto = entity.Adapt(); dto.CategoryName = entity.Category?.Name ?? String.Empty; - dto.Timestamp = entity.Timestamp.ToRemoteDateTime(hours); + dto.Timestamp = entity.Timestamp.ToOffset(TimeSpan.FromHours(hours)); return dto; } - private Measure Convert(MeasureDto dto, double hours) + private Measure Convert(MeasureDto dto) { var entity = dto.Adapt(); - entity.Timestamp = dto.Timestamp.ToUtcDateTimeOffset(hours); + entity.Timestamp = dto.Timestamp.ToUniversalTime(); return entity; } }