From 5644c06facf553c1b6276610499d6cd0e160d09b Mon Sep 17 00:00:00 2001 From: "ai.astrakhantsev" Date: Thu, 2 Feb 2023 12:04:50 +0500 Subject: [PATCH] =?UTF-8?q?#8103063=20=D0=97=D0=B0=D0=BC=D0=B5=D1=87=D0=B0?= =?UTF-8?q?=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../IProcessMapRepository.cs | 7 ++++--- .../Repository/ProcessMapRepository.cs | 7 ++++--- .../Repository/WellCompositeRepository.cs | 17 ++++++----------- .../Controllers/ProcessMapController.cs | 1 + 4 files changed, 15 insertions(+), 17 deletions(-) rename AsbCloudApp/{Services => Repositories}/IProcessMapRepository.cs (79%) diff --git a/AsbCloudApp/Services/IProcessMapRepository.cs b/AsbCloudApp/Repositories/IProcessMapRepository.cs similarity index 79% rename from AsbCloudApp/Services/IProcessMapRepository.cs rename to AsbCloudApp/Repositories/IProcessMapRepository.cs index 0469b2df..01dac891 100644 --- a/AsbCloudApp/Services/IProcessMapRepository.cs +++ b/AsbCloudApp/Repositories/IProcessMapRepository.cs @@ -1,11 +1,12 @@ using AsbCloudApp.Data.ProcessMap; using AsbCloudApp.Requests; +using AsbCloudApp.Services; using System; using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; -namespace AsbCloudApp.Services +namespace AsbCloudApp.Repositories { #nullable enable /// @@ -26,10 +27,10 @@ namespace AsbCloudApp.Services /// /// Получить параметры бурения /// - /// + /// /// /// - Task?> GetByRequesProcessMaplAsync(IEnumerable request, CancellationToken token); + Task?> GetProcessMaplAsync(IEnumerable requests, CancellationToken token); } #nullable disable } \ No newline at end of file diff --git a/AsbCloudInfrastructure/Repository/ProcessMapRepository.cs b/AsbCloudInfrastructure/Repository/ProcessMapRepository.cs index fda7fbb0..b138f068 100644 --- a/AsbCloudInfrastructure/Repository/ProcessMapRepository.cs +++ b/AsbCloudInfrastructure/Repository/ProcessMapRepository.cs @@ -1,5 +1,6 @@ using AsbCloudApp.Data; using AsbCloudApp.Data.ProcessMap; +using AsbCloudApp.Repositories; using AsbCloudApp.Requests; using AsbCloudApp.Services; using AsbCloudDb.Model; @@ -31,7 +32,7 @@ namespace AsbCloudInfrastructure.Repository public async Task> GetAllAsync(int idWell, DateTime? updateFrom, CancellationToken token) { - var request = new List + var request = new[] { new ProcessMapRequest { IdWell = idWell, @@ -49,9 +50,9 @@ namespace AsbCloudInfrastructure.Repository return dtos; } - public async Task?> GetByRequesProcessMaplAsync(IEnumerable request, CancellationToken token) + public async Task?> GetProcessMaplAsync(IEnumerable requests, CancellationToken token) { - var entities = await BuildQuery(request) + var entities = await BuildQuery(requests) .ToListAsync(token) .ConfigureAwait(false); var dtos = entities.Select(Convert).ToList(); diff --git a/AsbCloudInfrastructure/Repository/WellCompositeRepository.cs b/AsbCloudInfrastructure/Repository/WellCompositeRepository.cs index cbbf0e77..1951dd68 100644 --- a/AsbCloudInfrastructure/Repository/WellCompositeRepository.cs +++ b/AsbCloudInfrastructure/Repository/WellCompositeRepository.cs @@ -2,7 +2,6 @@ using AsbCloudApp.Data.ProcessMap; using AsbCloudApp.Repositories; using AsbCloudApp.Requests; -using AsbCloudApp.Services; using AsbCloudDb.Model; using Mapster; using Microsoft.EntityFrameworkCore; @@ -54,17 +53,13 @@ namespace AsbCloudInfrastructure.Repository public async Task?> GetCompositeProcessMap(int idWell, CancellationToken token) { var dtos = await GetAsync(idWell, token); - var request = new List(dtos.Count()); - foreach(var dto in dtos) - { - request.Add(new ProcessMapRequest - { - IdWell = dto.IdWellSrc, - IdWellSectionTypes = dto.IdWellSectionType - }); - }; - var processMap = (await processMapRepository.GetByRequesProcessMaplAsync(request, token)); + var request = dtos.Select(x => new ProcessMapRequest { + IdWell = x.IdWellSrc, + IdWellSectionTypes = x.IdWellSectionType + }); + + var processMap = (await processMapRepository.GetProcessMaplAsync(request, token)); var result = processMap?.Select(x => new ProcessMapDto { diff --git a/AsbCloudWebApi/Controllers/ProcessMapController.cs b/AsbCloudWebApi/Controllers/ProcessMapController.cs index f5c955aa..3a1430b9 100644 --- a/AsbCloudWebApi/Controllers/ProcessMapController.cs +++ b/AsbCloudWebApi/Controllers/ProcessMapController.cs @@ -1,4 +1,5 @@ using AsbCloudApp.Data.ProcessMap; +using AsbCloudApp.Repositories; using AsbCloudApp.Services; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc;