forked from ddrilling/AsbCloudServer
bug fixing in UserRepositoty.UpdateAsync
This commit is contained in:
parent
00a6a333e4
commit
b70fa35ef6
@ -101,13 +101,14 @@ namespace AsbCloudInfrastructure.Repository
|
|||||||
|
|
||||||
var userRoles = await userRoleRepository.GetByNamesAsync(dto.RoleNames, token).ConfigureAwait(false);
|
var userRoles = await userRoleRepository.GetByNamesAsync(dto.RoleNames, token).ConfigureAwait(false);
|
||||||
await UpdateRolesCacheForUserAsync(dto.Id, userRoles, token);
|
await UpdateRolesCacheForUserAsync(dto.Id, userRoles, token);
|
||||||
|
var userInDb = dbContext.Users.FirstOrDefault(u => u.Id == dto.Id);
|
||||||
var entity = Convert(dto);
|
if (userInDb is not null)
|
||||||
|
{
|
||||||
var result = dbContext.Users.Upsert(entity);
|
userInDb = Convert(dto);
|
||||||
await dbContext.SaveChangesAsync(token);
|
await dbContext.SaveChangesAsync(token);
|
||||||
|
}
|
||||||
DropCacheUsers();
|
DropCacheUsers();
|
||||||
return result.Entity.Id;
|
return userInDb!.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