using Evergreen.Health.Application.Health.Sleep; namespace Evergreen.Health.Application.Health.Integrations.Ib43; public sealed class Ib43AutomationExecutionLog(IServiceScopeFactory scopes) : IBedPresenceExecutionLog { public async Task BeginAsync(string bindingId, long userId, string action, string target, DateTimeOffset triggeredAt, CancellationToken token) { using var scope = scopes.CreateScope(); return await scope.ServiceProvider.GetRequiredService() .BeginAutomation(bindingId, userId, action, target, triggeredAt.ToUnixTimeMilliseconds(), token); } public async Task CompleteAsync(string id, string result, DateTimeOffset completedAt) { using var scope = scopes.CreateScope(); await scope.ServiceProvider.GetRequiredService() .CompleteAutomation(id, result, completedAt.ToUnixTimeMilliseconds()); } }