forked from ddrilling/AsbCloudServer
правка метода редактирования пользователя
согласно код-ревью
This commit is contained in:
parent
2cc8abd767
commit
2b02bdb0b8
@ -108,21 +108,20 @@ namespace AsbCloudInfrastructure.Repository
|
|||||||
await UpdateRolesCacheForUserAsync(dto.Id, userRoles, token);
|
await UpdateRolesCacheForUserAsync(dto.Id, userRoles, token);
|
||||||
|
|
||||||
var entity = dbContext.Users.FirstOrDefault(u => u.Id == dto.Id);
|
var entity = dbContext.Users.FirstOrDefault(u => u.Id == dto.Id);
|
||||||
if (entity is not null)
|
if (entity is null)
|
||||||
{
|
return -1;
|
||||||
entity.Id = dto.Id;
|
entity.Id = dto.Id;
|
||||||
entity.Name = dto.Name;
|
entity.Name = dto.Name;
|
||||||
entity.Email = dto.Email;
|
entity.Email = dto.Email;
|
||||||
entity.Phone = dto.Phone;
|
entity.Phone = dto.Phone;
|
||||||
entity.Surname = dto.Surname;
|
entity.Surname = dto.Surname;
|
||||||
entity.Patronymic = dto.Patronymic;
|
entity.Patronymic = dto.Patronymic;
|
||||||
entity.Position = dto.Position;
|
entity.Position = dto.Position;
|
||||||
entity.IdCompany = dto.IdCompany;
|
entity.IdCompany = dto.IdCompany;
|
||||||
entity.IdState = dto.IdState;
|
entity.IdState = dto.IdState;
|
||||||
await dbContext.SaveChangesAsync(token);
|
await dbContext.SaveChangesAsync(token);
|
||||||
}
|
|
||||||
DropCacheUsers();
|
DropCacheUsers();
|
||||||
return entity!.Id;
|
return entity.Id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<int> DeleteAsync(int id, CancellationToken token)
|
public async Task<int> DeleteAsync(int id, CancellationToken token)
|
||||||
|
Loading…
Reference in New Issue
Block a user