bug fixing in UserRepositoty.UpdateAsync

This commit is contained in:
eugeniy_ivanov 2023-02-02 15:21:48 +05:00
parent 00a6a333e4
commit b70fa35ef6

View File

@ -101,13 +101,14 @@ namespace AsbCloudInfrastructure.Repository
var userRoles = await userRoleRepository.GetByNamesAsync(dto.RoleNames, token).ConfigureAwait(false);
await UpdateRolesCacheForUserAsync(dto.Id, userRoles, token);
var entity = Convert(dto);
var result = dbContext.Users.Upsert(entity);
var userInDb = dbContext.Users.FirstOrDefault(u => u.Id == dto.Id);
if (userInDb is not null)
{
userInDb = Convert(dto);
await dbContext.SaveChangesAsync(token);
}
DropCacheUsers();
return result.Entity.Id;
return userInDb!.Id;
}
public async Task<int> DeleteAsync(int id, CancellationToken token)