Implement registry update
This commit is contained in:
@ -122,6 +122,17 @@ namespace Hcs.WebApp.Services
|
||||
}
|
||||
}
|
||||
|
||||
public async Task SetOperationEndedAsync(HcsDbContext context, int operationId)
|
||||
{
|
||||
var operation = await context.Operations.FirstOrDefaultAsync(x => x.Id == operationId);
|
||||
if (operation != null)
|
||||
{
|
||||
operation.EndedAt = DateTime.UtcNow;
|
||||
|
||||
await context.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
|
||||
public async Task SetOperationEndedWithFailAsync(int operationId, string failureReason)
|
||||
{
|
||||
using var context = GetNewContext();
|
||||
|
||||
@ -21,6 +21,17 @@ namespace Hcs.WebApp.Services
|
||||
public async Task<Registry> GetRegistryByOperationIdAsync(int operationId)
|
||||
{
|
||||
using var context = GetNewContext();
|
||||
return await GetRegistryByOperationIdAsync(context, operationId);
|
||||
}
|
||||
|
||||
public async Task<Registry> GetRegistryByOperationIdAsync(HcsDbContext context, int operationId, bool includeElements = false)
|
||||
{
|
||||
if (includeElements)
|
||||
{
|
||||
return await context.Registries
|
||||
.Include(x => x.Elements)
|
||||
.SingleAsync(x => x.LastSyncOperationId == operationId);
|
||||
}
|
||||
return await context.Registries.SingleAsync(x => x.LastSyncOperationId == operationId);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user