Occupancy script udpate
This commit is contained in:
parent
118e66ceca
commit
30194d5832
|
@ -241,25 +241,32 @@ private async Task EvaluateOccupancyAsync(Tenant tenant, int newOccupancyValue,
|
|||
|
||||
private async Task AddRemoveOccupancyAccessLevelAsync(int tenantId, bool remove)
|
||||
{
|
||||
var filterId = await CreateCompanyFilterAsync(tenantId);
|
||||
int filterId = await CreateCompanyFilterAsync(tenantId);
|
||||
|
||||
try
|
||||
{
|
||||
await Context.BulkUpdateUsersAsync(0, 1000, Array.Empty<int>(), new BulkUpdateUser
|
||||
{
|
||||
AccessLevels =
|
||||
IEnumerable<Grpc.AccessLevel> als = await Context.GetAccessLevelsAsync();
|
||||
|
||||
List<EntityUpdate> toUpdate = als.Where(e => e.Id != Configuration.AccessLevelId).Select(e =>
|
||||
new EntityUpdate()
|
||||
{
|
||||
new EntityUpdate[]
|
||||
{
|
||||
new()
|
||||
{
|
||||
Id = Configuration.AccessLevelId,
|
||||
Remove = remove,
|
||||
Update = true
|
||||
}
|
||||
}
|
||||
Id = e.Id,
|
||||
Remove = false,
|
||||
Update = false
|
||||
}).ToList();
|
||||
|
||||
toUpdate.Add(new EntityUpdate
|
||||
{
|
||||
Id = Configuration.AccessLevelId,
|
||||
Remove = remove,
|
||||
Update = true
|
||||
}
|
||||
}, filterId);
|
||||
);
|
||||
|
||||
var bulkUpdateUserRequest = new BulkUpdateUser();
|
||||
bulkUpdateUserRequest.AccessLevels.AddRange(toUpdate);
|
||||
|
||||
await Context.BulkUpdateUsersAsync(0, 100000, Array.Empty<int>(), bulkUpdateUserRequest, filterId);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue