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 ClusterService : IClusterService { private readonly IAsbCloudDbContext db; public ClusterService(IAsbCloudDbContext db) { this.db = db; } public IEnumerable 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 GetClusters(int idCustomer) { var entities = db.GetWellsByCustomer(idCustomer) .Select(e => e.Cluster) .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 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 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 GetAnalysis(int idCustomer, int clusterId) { throw new NotImplementedException(); } } }