using PARR.EsppOrderManager;

namespace PARR.EsppOrderManagerWorker
{
    public class Worker : BackgroundService
    {
        private readonly ILogger<Worker> _logger;
        private readonly IEsppOrderManager esppOrderManager;

        public Worker(ILogger<Worker> logger, IEsppOrderManager esppOrderManager)
        {
            _logger = logger;
            this.esppOrderManager = esppOrderManager;
        }

        protected override async Task ExecuteAsync(CancellationToken stoppingToken)
        {
           await esppOrderManager.StartAsync();
        }

        public override Task StopAsync(CancellationToken cancellationToken)
        {
            esppOrderManager.StopAsync().Wait();

            return base.StopAsync(cancellationToken);
        }
    }
}