using ECMJobRunner.Application.Common.Dtos;
using ECMJobRunner.Application.Profiles.Commands;
using MediatR;
namespace ECMJobRunner.WebCron.Extensions;
///
/// Extension methods for profile DTOs to support Hangfire job operations.
///
public static class DtoExtensions
{
///
/// Generates a unique Hangfire job identifier for a profile.
///
/// The profile configuration DTO.
/// A unique job identifier in the format "profile-{Id}-{normalized-name}".
///
/// Example: profile with Id=123 and ProfileName="Import Data"
/// returns "profile-123-import_data"
///
public static string JobId(this CfgProfileDto profile)
{
return $"profile-{profile.Id}-{profile.ProfileName.Replace(' ', '_').ToLowerInvariant()}";
}
///
/// Converts a profile DTO to a DEX job batch command.
///
/// The profile configuration DTO.
/// A ready to execute the profile job.
public static TriggeringProfileJobBatchCommand ToJob(this CfgProfileDto profile)
{
return new TriggeringProfileJobBatchCommand
{
ProfileId = profile.Id,
};
}
}