Complete campaign flow
This commit is contained in:
@ -5,6 +5,11 @@ namespace Hcs.WebApp.Services
|
||||
{
|
||||
public class RegistryService(IDbContextFactory<HcsDbContext> factory) : HcsServiceBase(factory)
|
||||
{
|
||||
public async Task<int> GetRegistryCountAsync(HcsDbContext context)
|
||||
{
|
||||
return await context.Registries.CountAsync();
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<Registry>> GetAllRegistriesAsync(bool isCommon)
|
||||
{
|
||||
using var context = GetNewContext();
|
||||
@ -19,7 +24,7 @@ namespace Hcs.WebApp.Services
|
||||
return await context.Registries.SingleAsync(x => x.LastSyncOperationId == operationId);
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<Registry>> GetRegistriesByOperationId(int operationId)
|
||||
public async Task<IEnumerable<Registry>> GetRegistriesByOperationIdAsync(int operationId)
|
||||
{
|
||||
using var context = GetNewContext();
|
||||
return await (from registry in context.Registries
|
||||
@ -27,9 +32,10 @@ namespace Hcs.WebApp.Services
|
||||
select registry).ToListAsync();
|
||||
}
|
||||
|
||||
public async Task SetOperationIdToAllRegistries(HcsDbContext context, int operationId)
|
||||
public async Task SetOperationsToRegistriesAsync(HcsDbContext context, IEnumerable<Operation> operations)
|
||||
{
|
||||
await context.Registries.ForEachAsync(x => x.LastSyncOperationId = operationId);
|
||||
var queue = new Queue<Operation>(operations);
|
||||
await context.Registries.ForEachAsync(x => x.LastSyncOperationId = queue.Dequeue().Id);
|
||||
await context.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user