﻿using Hangfire;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;

namespace indevio.Infrastructure.TaskScheduling
{
    public static class HangfireConfigurator
    {
        public static IServiceCollection ConfigureTaskScheduler(this IServiceCollection services, string connectionString)
        {
            services.AddHangfire(config => config.UseSqlServerStorage(connectionString));
            return services;
        }

        public static IApplicationBuilder UseTaskScheduler(this IApplicationBuilder builder)
        {
            builder.UseHangfireDashboard();
            builder.UseHangfireServer();

            return builder;
        }
    }
}
