From 1fd00256e94cd400cd33403315550377c57223ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D1=82=D0=B5=D0=BF=D0=B0=D0=BD=D0=BE=D0=B2=20=D0=94?= =?UTF-8?q?=D0=BC=D0=B8=D1=82=D1=80=D0=B8=D0=B9?= Date: Fri, 20 Oct 2023 15:46:44 +0500 Subject: [PATCH] =?UTF-8?q?=D0=A4=D0=B8=D0=BA=D1=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. Возник баг если обновлять скважину из состояния в работе -> завершена и обратно возникает ошибка, что скважина отслеживается контекстом. 2. Поправил метод контроллера UpdateWellStateAsync --- AsbCloudInfrastructure/Services/WellService.cs | 3 ++- AsbCloudWebApi/Controllers/WellController.cs | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/AsbCloudInfrastructure/Services/WellService.cs b/AsbCloudInfrastructure/Services/WellService.cs index 1a907725..105cb5b3 100644 --- a/AsbCloudInfrastructure/Services/WellService.cs +++ b/AsbCloudInfrastructure/Services/WellService.cs @@ -33,7 +33,8 @@ namespace AsbCloudInfrastructure.Services .Include(w => w.Telemetry) .Include(w => w.WellType) .Include(w => w.RelationCompaniesWells) - .ThenInclude(r => r.Company); + .ThenInclude(r => r.Company) + .AsNoTracking(); public WellService(IAsbCloudDbContext db, IMemoryCache memoryCache, ITelemetryService telemetryService, ITimezoneService timezoneService, WellInfoService wellInfoService) : base(db, memoryCache, MakeQueryWell) diff --git a/AsbCloudWebApi/Controllers/WellController.cs b/AsbCloudWebApi/Controllers/WellController.cs index 3ed37d65..51e215ca 100644 --- a/AsbCloudWebApi/Controllers/WellController.cs +++ b/AsbCloudWebApi/Controllers/WellController.cs @@ -135,8 +135,8 @@ namespace AsbCloudWebApi.Controllers idWell, token).ConfigureAwait(false)) return Forbid(); - var dto = wellService.GetOrDefault(idWell)!; - dto.IdState = idState; + var dto = await wellService.GetOrDefaultAsync(idWell, token); + dto!.IdState = idState; var result = await wellService.UpdateAsync(dto, token) .ConfigureAwait(false);