Fixed location update does not cause update of assets and users, fixed ldap async issue

This commit is contained in:
2025-11-16 21:47:33 +01:00
parent 465f01f934
commit 95111a6a3d
3 changed files with 38 additions and 11 deletions

View File

@@ -69,6 +69,8 @@ public class LocationsController : Controller
}
try
{
LocationModel location = await _ldap.GetLocationByCnAsync(cn);
await SynchronizationHelper.SyncLocationName(_ldap, location.Location, "");
await _ldap.DeleteLocationAsync(cn);
return new(true);
}
@@ -92,7 +94,7 @@ public class LocationsController : Controller
string location = requestModel.Location;
LocationsDescription room = requestModel.Description;
string newLocation = StringHelpers.Slugify(room.Location + " " + room.RoomNumber + " " + room.Seat); // TODO: fix DRY violation
await SynchronizationHelper.SyncLocationName(_ldap, location, newLocation);
await _ldap.UpdateLocation(location, "description", JsonSerializer.Serialize(room));
await _ldap.UpdateLocation(location, "l", newLocation);
return new LocationsUpdateResponseModel { Success = true };

View File

@@ -51,9 +51,8 @@ public class UsersController : Controller
{
try
{
var syncAssetOwnership = SynchronizationHelper.SyncAssetOwnership(_ldap, uid, "");
await SynchronizationHelper.SyncAssetOwnership(_ldap, uid, "");
await _ldap.DeleteUserAsync(uid);
await syncAssetOwnership;
return new UsersDeleteRequestModel(true);
}
catch (Exception ex)
@@ -124,10 +123,9 @@ public class UsersController : Controller
UserModel? user = null;
if (requestModel.NewUid is not null && requestModel.NewUid.Length > 0)
{
var syncAssetOwnership = SynchronizationHelper.SyncAssetOwnership(_ldap, uid, requestModel.NewUid);
await SynchronizationHelper.SyncAssetOwnership(_ldap, uid, requestModel.NewUid);
await _ldap.UpdateUser(uid, "uid", requestModel.NewUid);
uid = requestModel.NewUid;
await syncAssetOwnership;
}
if (requestModel.Title is not null)
{
@@ -170,10 +168,9 @@ public class UsersController : Controller
}
if (newUid != uid)
{
var syncAssetOwnership = SynchronizationHelper.SyncAssetOwnership(_ldap, uid, newUid);
await SynchronizationHelper.SyncAssetOwnership(_ldap, uid, newUid);
await _ldap.UpdateUser(uid, "uid", newUid);
uid = newUid;
await syncAssetOwnership;
}
return new() { Success = true, NewUid = uid };
} catch (Exception ex)