Update common registries page
This commit is contained in:
16
Hcs.WebApp/Services/OperationService.cs
Normal file
16
Hcs.WebApp/Services/OperationService.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using Hcs.WebApp.Data.Hcs;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Hcs.WebApp.Services
|
||||
{
|
||||
public class OperationService(IDbContextFactory<HcsDbContext> factory)
|
||||
{
|
||||
private readonly IDbContextFactory<HcsDbContext> factory = factory;
|
||||
|
||||
public async Task<bool> HasActiveOperation(Operation.OperationType type)
|
||||
{
|
||||
using var context = factory.CreateDbContext();
|
||||
return await context.Operations.AnyAsync(x => x.Type == type && !x.EndedAt.HasValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
18
Hcs.WebApp/Services/RegistryService.cs
Normal file
18
Hcs.WebApp/Services/RegistryService.cs
Normal file
@ -0,0 +1,18 @@
|
||||
using Hcs.WebApp.Data.Hcs;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Hcs.WebApp.Services
|
||||
{
|
||||
public class RegistryService(IDbContextFactory<HcsDbContext> factory)
|
||||
{
|
||||
private readonly IDbContextFactory<HcsDbContext> factory = factory;
|
||||
|
||||
public async Task<IEnumerable<Registry>> GetAllRegistries(bool isCommon)
|
||||
{
|
||||
using var context = factory.CreateDbContext();
|
||||
return await (from registry in context.Registries
|
||||
where registry.IsCommon == isCommon
|
||||
select registry).ToListAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user