Treat common and private registries separately
This commit is contained in:
@ -5,9 +5,9 @@ namespace Hcs.WebApp.Services
|
||||
{
|
||||
public class RegistryService(IDbContextFactory<HcsDbContext> factory) : HcsServiceBase(factory)
|
||||
{
|
||||
public async Task<int> GetRegistryCountAsync(HcsDbContext context)
|
||||
public async Task<int> GetRegistryCountAsync(HcsDbContext context, bool isCommon)
|
||||
{
|
||||
return await context.Registries.CountAsync();
|
||||
return await context.Registries.CountAsync(x => x.IsCommon == isCommon);
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<Registry>> GetAllRegistriesAsync(bool isCommon)
|
||||
@ -32,10 +32,16 @@ namespace Hcs.WebApp.Services
|
||||
select registry).ToListAsync();
|
||||
}
|
||||
|
||||
public async Task SetOperationsToRegistriesAsync(HcsDbContext context, IEnumerable<Operation> operations)
|
||||
public async Task SetOperationsToRegistriesAsync(HcsDbContext context, bool isCommon, IEnumerable<Operation> operations)
|
||||
{
|
||||
var queue = new Queue<Operation>(operations);
|
||||
await context.Registries.ForEachAsync(x => x.LastSyncOperationId = queue.Dequeue().Id);
|
||||
await context.Registries.ForEachAsync(x =>
|
||||
{
|
||||
if (x.IsCommon == isCommon)
|
||||
{
|
||||
x.LastSyncOperationId = queue.Dequeue().Id;
|
||||
}
|
||||
});
|
||||
await context.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user