2023-09-25 11:56:40 +05:00
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
|
|
|
using System.Threading;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
using AsbCloudApp.Data.ProcessMap;
|
|
|
|
using AsbCloudApp.Repositories;
|
|
|
|
using AsbCloudApp.Services;
|
|
|
|
using AsbCloudDb.Model;
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
|
|
|
|
namespace AsbCloudInfrastructure.Repository;
|
|
|
|
|
|
|
|
public class ProcessMapWellboreDevelopmentRepository :
|
|
|
|
CrudWellRelatedRepositoryBase<ProcessMapWellboreDevelopmentDto, ProcessMapWellboreDevelopment>,
|
|
|
|
IProcessMapWellboreDevelopmentRepository
|
|
|
|
{
|
|
|
|
private readonly IWellService wellService;
|
|
|
|
|
|
|
|
public ProcessMapWellboreDevelopmentRepository(IAsbCloudDbContext context, IWellService wellService) : base(context)
|
|
|
|
{
|
|
|
|
this.wellService = wellService;
|
|
|
|
}
|
|
|
|
|
|
|
|
public async Task<IEnumerable<ProcessMapWellboreDevelopmentDto>> GetAllAsync(int idWell, DateTime? updateFrom,
|
|
|
|
CancellationToken cancellationToken)
|
|
|
|
{
|
|
|
|
var query = dbContext.ProcessMapWellboreDevelopments
|
|
|
|
.Where(p => p.IdWell == idWell);
|
|
|
|
|
|
|
|
if (updateFrom.HasValue)
|
|
|
|
{
|
|
|
|
var timezone = wellService.GetTimezone(idWell);
|
|
|
|
var updateFromUtc = updateFrom.Value.ToUtcDateTimeOffset(timezone.Hours);
|
|
|
|
query = query.Where(p => p.LastUpdate >= updateFromUtc);
|
|
|
|
}
|
|
|
|
|
|
|
|
var entities = await query
|
|
|
|
.OrderBy(p => p.DepthStart)
|
|
|
|
.ThenBy(p => p.Id)
|
2023-09-26 14:31:37 +05:00
|
|
|
.AsNoTracking()
|
2023-09-25 11:56:40 +05:00
|
|
|
.ToArrayAsync(cancellationToken);
|
|
|
|
|
|
|
|
return entities.Select(Convert);
|
|
|
|
}
|
|
|
|
}
|