From 2b02bdb0b895e7dde52c83e668cb2f8a07a5a992 Mon Sep 17 00:00:00 2001 From: eugeniy_ivanov Date: Tue, 14 Feb 2023 12:30:05 +0500 Subject: [PATCH] =?UTF-8?q?=D0=BF=D1=80=D0=B0=D0=B2=D0=BA=D0=B0=20=D0=BC?= =?UTF-8?q?=D0=B5=D1=82=D0=BE=D0=B4=D0=B0=20=D1=80=D0=B5=D0=B4=D0=B0=D0=BA?= =?UTF-8?q?=D1=82=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D1=8F=20=D0=BF?= =?UTF-8?q?=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB?= =?UTF-8?q?=D1=8F=20=D1=81=D0=BE=D0=B3=D0=BB=D0=B0=D1=81=D0=BD=D0=BE=20?= =?UTF-8?q?=D0=BA=D0=BE=D0=B4-=D1=80=D0=B5=D0=B2=D1=8C=D1=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Repository/UserRepository.cs | 27 +++++++++---------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/AsbCloudInfrastructure/Repository/UserRepository.cs b/AsbCloudInfrastructure/Repository/UserRepository.cs index e1ca6c19..fa69ac0d 100644 --- a/AsbCloudInfrastructure/Repository/UserRepository.cs +++ b/AsbCloudInfrastructure/Repository/UserRepository.cs @@ -108,21 +108,20 @@ namespace AsbCloudInfrastructure.Repository await UpdateRolesCacheForUserAsync(dto.Id, userRoles, token); var entity = dbContext.Users.FirstOrDefault(u => u.Id == dto.Id); - if (entity is not null) - { - entity.Id = dto.Id; - entity.Name = dto.Name; - entity.Email = dto.Email; - entity.Phone = dto.Phone; - entity.Surname = dto.Surname; - entity.Patronymic = dto.Patronymic; - entity.Position = dto.Position; - entity.IdCompany = dto.IdCompany; - entity.IdState = dto.IdState; - await dbContext.SaveChangesAsync(token); - } + if (entity is null) + return -1; + entity.Id = dto.Id; + entity.Name = dto.Name; + entity.Email = dto.Email; + entity.Phone = dto.Phone; + entity.Surname = dto.Surname; + entity.Patronymic = dto.Patronymic; + entity.Position = dto.Position; + entity.IdCompany = dto.IdCompany; + entity.IdState = dto.IdState; + await dbContext.SaveChangesAsync(token); DropCacheUsers(); - return entity!.Id; + return entity.Id; } public async Task DeleteAsync(int id, CancellationToken token)