Start operation implementation
This commit is contained in:
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user