forked from ddrilling/AsbCloudServer
Степанов Дмитрий
ef54d3bb20
1. Добавлена реализация сервиса 2. Добавлена реализация репозитория 3. Добавил контроллер для проработки скважины 4. Зарегистрировал все новые зависимости
45 lines
1.3 KiB
C#
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);
|
|
}
|
|
} |