DD.WellWorkover.Cloud/AsbCloudInfrastructure/Services/СlusterService.cs

85 lines
2.3 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using AsbCloudApp.Data;
using AsbCloudApp.Services;
using AsbCloudDb.Model;
using AsbCloudInfrastructure.Services.Cache;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AsbCloudInfrastructure.Services
{
public class СlusterService : IClusterService
{
private readonly IAsbCloudDbContext db;
public СlusterService(IAsbCloudDbContext db)
{
this.db = db;
}
public IEnumerable<DepositDto> GetDeposits(int idCustomer)
{
var entities = db.GetWellsByCustomer(idCustomer)
.Select(e=>e.Cluster.Deposit)
.Distinct()
.ToList();
var dtos = entities.Select(e => new DepositDto
{
Id = e.Id,
Name = e.Caption,
Latitude = e.Latitude,
Longitude = e.Longitude,
});
return dtos;
}
public IEnumerable<ClusterDto> GetClusters(int idCustomer, int depositId)
{
var entities = db.GetWellsByCustomer(idCustomer)
.Select(e => e.Cluster)
.Where(e=>e.IdDeposit == depositId)
.Distinct()
.ToList();
var dtos = entities.Select(e => new ClusterDto
{
Id = e.Id,
Name = e.Caption,
Latitude = e.Latitude,
Longitude = e.Longitude,
});
return dtos;
}
public IEnumerable<WellDto> GetWells(int idCustomer, int clusterId)
{
var entities = db.GetWellsByCustomer(idCustomer)
.Where(e => e.IdCluster == clusterId)
.ToList();
var dtos = entities.Select(e => new WellDto
{
Id = e.Id,
Caption = e.Caption,
Latitude = e.Latitude,
Longitude = e.Longitude,
Cluster = e.Cluster.Caption,
Deposit = e.Cluster.Deposit.Caption,
});
return dtos;
}
public IEnumerable<ClusterAnalysisDto> GetAnalysis(int idCustomer, int clusterId)
{
throw new NotImplementedException();
}
}
}