From bf3a910433553c490adb6abbf8c89a1cf6a5813e Mon Sep 17 00:00:00 2001 From: "ai.astrakhantsev" Date: Wed, 14 Dec 2022 09:10:01 +0500 Subject: [PATCH 1/2] #7987467 fix --- .../Repository/ProcessMapRepository.cs | 25 +++++++++++++++++-- .../Controllers/ProcessMapController.cs | 2 +- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/AsbCloudInfrastructure/Repository/ProcessMapRepository.cs b/AsbCloudInfrastructure/Repository/ProcessMapRepository.cs index 0090c752..eb2eadac 100644 --- a/AsbCloudInfrastructure/Repository/ProcessMapRepository.cs +++ b/AsbCloudInfrastructure/Repository/ProcessMapRepository.cs @@ -85,8 +85,8 @@ namespace AsbCloudInfrastructure.Repository }; dto.Pressure = new PlanFactDto { - Fact = entity.FlowFact, - Plan = entity.FlowPlan + Fact = entity.PressureFact, + Plan = entity.PressurePlan }; dto.TopDriveSpeed = new PlanFactDto { @@ -100,6 +100,27 @@ namespace AsbCloudInfrastructure.Repository }; return dto; } + + protected override ProcessMap Convert(ProcessMapDto dto) + { + var entity = dto.Adapt(); + entity.AxialLoadPlan = dto.AxialLoad.Plan; + entity.AxialLoadFact = dto.AxialLoad.Fact; + + entity.FlowPlan = dto.Flow.Plan; + entity.FlowFact = dto.Flow.Fact; + + entity.PressurePlan = dto.Pressure.Plan; + entity.PressureFact = dto.Pressure.Fact; + + entity.TopDriveSpeedPlan = dto.TopDriveSpeed.Plan; + entity.TopDriveSpeedFact = dto.TopDriveSpeed.Fact; + + entity.TopDriveTorquePlan = dto.TopDriveTorque.Plan; + entity.TopDriveTorqueFact = dto.TopDriveTorque.Fact; + + return entity; + } } #nullable disable } \ No newline at end of file diff --git a/AsbCloudWebApi/Controllers/ProcessMapController.cs b/AsbCloudWebApi/Controllers/ProcessMapController.cs index a547fae4..6d4681ed 100644 --- a/AsbCloudWebApi/Controllers/ProcessMapController.cs +++ b/AsbCloudWebApi/Controllers/ProcessMapController.cs @@ -110,7 +110,7 @@ namespace AsbCloudWebApi.Controllers public override async Task> UpdateAsync([FromBody] ProcessMapDto value, CancellationToken token) { value.IdUser = User.GetUserId() ?? -1; - return await base.InsertAsync(value, token); + return await base.UpdateAsync(value, token); } } #nullable disable From 1f70868120ae7ef58af9fa8b99ab407baef70809 Mon Sep 17 00:00:00 2001 From: "ai.astrakhantsev" Date: Wed, 14 Dec 2022 10:38:44 +0500 Subject: [PATCH 2/2] #8242403 fix --- .../Repository/UserRepository.cs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/AsbCloudInfrastructure/Repository/UserRepository.cs b/AsbCloudInfrastructure/Repository/UserRepository.cs index 3a52d030..efc0db16 100644 --- a/AsbCloudInfrastructure/Repository/UserRepository.cs +++ b/AsbCloudInfrastructure/Repository/UserRepository.cs @@ -35,27 +35,28 @@ namespace AsbCloudInfrastructure.Repository this.userRoleRepository = userRoleRepository; } - public async Task InsertAsync(UserExtendedDto dto, CancellationToken token = default) + public async Task InsertAsync(UserExtendedDto dto, CancellationToken token) { dto.Id = default; var entity = Convert(dto); await AssertLoginIsBusyAsync(dto.Login, token); var userRoles = await userRoleRepository.GetByNamesAsync(dto.RoleNames, token).ConfigureAwait(false); var updatedEntity = await dbContext.Users.AddAsync(entity, token).ConfigureAwait(false); + await dbContext.SaveChangesAsync(token); + if (userRoles?.Any() == true) await UpdateRolesCacheForUserAsync(updatedEntity.Entity.Id, userRoles, token); - await dbContext.SaveChangesAsync(token); DropCacheUsers(); return updatedEntity.Entity.Id; } - public Task InsertRangeAsync(IEnumerable newItems, CancellationToken token = default) + public Task InsertRangeAsync(IEnumerable newItems, CancellationToken token) { throw new NotImplementedException(); } - public async Task> GetAllAsync(CancellationToken token = default) + public async Task> GetAllAsync(CancellationToken token) { var dtos = (await GetCacheUserAsync(token)).ToList(); if (dtos is null) @@ -76,7 +77,7 @@ namespace AsbCloudInfrastructure.Repository return dto; } - public async Task GetOrDefaultAsync(int id, CancellationToken token = default) + public async Task GetOrDefaultAsync(int id, CancellationToken token) { var dto = (await GetCacheUserAsync(token)).FirstOrDefault(u => u.Id == id); if (dto is null) @@ -86,7 +87,7 @@ namespace AsbCloudInfrastructure.Repository return dto; } - public async Task UpdateAsync(UserExtendedDto dto, CancellationToken token = default) + public async Task UpdateAsync(UserExtendedDto dto, CancellationToken token) { if (dto.Id <= 1) throw new ArgumentInvalidException($"Invalid id {dto.Id}. You can't edit this user.", nameof(dto)); @@ -109,7 +110,7 @@ namespace AsbCloudInfrastructure.Repository return result.Entity.Id; } - public async Task DeleteAsync(int id, CancellationToken token = default) + public async Task DeleteAsync(int id, CancellationToken token) { var dto = (await GetCacheUserAsync(token)).FirstOrDefault(u => u.Id == id); if (dto is null) @@ -159,7 +160,7 @@ namespace AsbCloudInfrastructure.Repository .Select(r => r.Caption) .Distinct(); - private async Task AssertLoginIsBusyAsync(string login, CancellationToken token = default) + private async Task AssertLoginIsBusyAsync(string login, CancellationToken token) { var existingUserDto = (await GetCacheUserAsync(token)) .FirstOrDefault(u => u.Login.ToLower() == login.ToLower());