using Microsoft.Extensions.Logging;
using PARR.DAL.Services.Interfaces.Job;

namespace PARR.TemplateTaskGenerator.Services
{
    internal class ValidatorService : IValidatorService
    {
        private readonly ILogger<ValidatorService> logger;
        private readonly IJobService jobService;


        public ValidatorService(
            ILogger<ValidatorService> logger,
            IJobService jobService
            )
        {
            this.logger = logger;
            this.jobService = jobService;
        }


        public async Task<bool> IsValidAsync(Guid jobId)
        {
            var isExist = await jobService.GetAsync(jobId);

            if (isExist == null)
            {
                logger.LogError($"Не найдена регалментная работа {nameof(jobId)}: {jobId}");
                return false;
            }

            return true;
        }

    }
}
