DD.WellWorkover.Cloud/AsbCloudInfrastructure/Repository/ProcessMapWellboreDevelopmentRepository.cs
Степанов Дмитрий ef54d3bb20 Добавление логики для проработки скважины
1. Добавлена реализация сервиса
2. Добавлена реализация репозитория
3. Добавил контроллер для проработки скважины
4. Зарегистрировал все новые зависимости
2023-09-25 11:56:40 +05:00

45 lines
1.3 KiB
C#

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)
.ToArrayAsync(cancellationToken);
return entities.Select(Convert);
}
}