17 lines
524 B
C#
17 lines
524 B
C#
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);
|
|
}
|
|
}
|
|
}
|