DD.WellWorkover.Cloud/AsbCloudInfrastructure/Repository/SetpointsRequestRepository.cs

37 lines
1.3 KiB
C#
Raw Normal View History

using AsbCloudApp.Data.SAUB;
using AsbCloudApp.Services;
using AsbCloudDb.Model;
using Microsoft.EntityFrameworkCore;
using System;
namespace AsbCloudInfrastructure.Repository
{
public class SetpointsRequestRepository : CrudWellRelatedCacheServiceBase<SetpointsRequestDto, SetpointsRequest>
{
private readonly IWellService wellService;
public SetpointsRequestRepository(IAsbCloudDbContext dbContext, IWellService wellService)
: base(dbContext, q => q.Include(s => s.Author)
.Include(s => s.Well))
{
this.wellService = wellService;
}
protected override SetpointsRequestDto Convert(SetpointsRequest src)
{
var result = base.Convert(src);
var timezoneOffsetHours = wellService.GetTimezone(src.IdWell).Hours;
result.UploadDate = src.UploadDate.ToRemoteDateTime(timezoneOffsetHours);
return result;
}
protected override SetpointsRequest Convert(SetpointsRequestDto src)
{
var result = base.Convert(src);
var timezoneOffsetHours = wellService.GetTimezone(src.IdWell).Hours;
result.UploadDate = src.UploadDate.ToUtcDateTimeOffset(timezoneOffsetHours);
return result;
}
}
}