using Microsoft.Extensions.Logging;
using PARR.Core.Repositories.Interfaces.Job;
using PARR.TemplateMatcher.Services.Interfaces;

namespace PARR.TemplateMatcher.Services.Implemetaions
{
    internal class JobValidatorService : IJobValidatorService
    {
        private readonly ILogger<IJobValidatorService> logger;
        private readonly IJobRepository jobService;

        public JobValidatorService(
            ILogger<IJobValidatorService> logger,
            IJobRepository jobService
            )
        {
            this.logger = logger;
            this.jobService = jobService;
        }
        public async Task<bool> IsValidJobAsync(Guid jobId)
        {
            var isExist = await jobService.GetAsync(jobId);

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

            return true;
        }
    }
}
