DD.WellWorkover.Cloud/AsbCloudInfrastructure/Services/WellSectionService.cs
2021-08-10 14:36:35 +05:00

89 lines
2.6 KiB
C#

using AsbCloudApp.Data;
using AsbCloudApp.Services;
using AsbCloudDb.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Mapster;
using Microsoft.EntityFrameworkCore;
using System.Threading.Tasks;
using System.Threading;
namespace AsbCloudInfrastructure.Services
{
public class WellSectionService: IWellSectionService
{
private readonly IAsbCloudDbContext context;
private readonly DbSet<WellSection> dbSet;
public WellSectionService(IAsbCloudDbContext context)
{
this.context = context;
dbSet = context.Set<WellSection>();
}
public Task<WellSectionDto> GetAsync(int id, CancellationToken token = default)
{
throw new NotImplementedException();
}
public Task<WellSectionDto> InsertAsync(WellSectionDto newItem, CancellationToken token = default)
{
throw new NotImplementedException();
}
public Task<IEnumerable<WellSectionDto>> InsertRangeAsync(IEnumerable<WellSectionDto> newItems, CancellationToken token = default)
{
throw new NotImplementedException();
}
public Task<WellSectionDto> UpdateAsync(WellSectionDto item, CancellationToken token = default)
{
throw new NotImplementedException();
}
public async Task<PaginationContainer<WellSectionDto>> GetAllByWellIdAsync(int idWell, int skip, int take, CancellationToken token = default)
{
var query = dbSet
.Include(s => s.WellSectionType)
.Where(s => s.IdWell == idWell)
.AsNoTracking();
var result = new PaginationContainer<WellSectionDto>
{
Skip = skip,
Take = take,
Count = await query.CountAsync(token).ConfigureAwait(false),
};
query = query
.OrderBy(e => e.WellDepthPlan);
if (skip > 0)
query = query.Skip(skip);
query = query.Take(take);
var entities = await query.Take(take).ToListAsync(token).ConfigureAwait(false);
foreach (var item in entities)
result.Items.Add(item.Adapt<WellSectionDto>());
return result;
}
public Task<int> DeleteAsync(int id, CancellationToken token = default)
{
throw new NotImplementedException();
}
public Task<int> DeleteAsync(IEnumerable<int> ids, CancellationToken token = default)
{
throw new NotImplementedException();
}
}
}