Start operation implementation

This commit is contained in:
2025-10-23 18:15:25 +09:00
parent 0626ce0176
commit 608dcc2098
5 changed files with 97 additions and 3 deletions

View File

@ -12,5 +12,19 @@ namespace Hcs.WebApp.Services
using var context = factory.CreateDbContext();
return await context.Operations.AnyAsync(x => x.Type == type && !x.EndedAt.HasValue);
}
public async Task<Operation> InitiateOperation(Operation.OperationType type, string initiatorId)
{
using var context = factory.CreateDbContext();
var operation = new Operation()
{
Type = type,
InitiatorId = initiatorId,
StartedAt = DateTime.UtcNow
};
await context.Operations.AddAsync(operation);
await context.SaveChangesAsync();
return operation;
}
}
}