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

namespace PARR.TemplateMatcher.Services.Implemetaions
{
    internal class JobGroupValidatorService : IJobGroupValidatorService
    {
        private readonly ILogger<IJobValidatorService> logger;
        private readonly IJobGroupService jobGroupService;

        public JobGroupValidatorService(
            ILogger<IJobValidatorService> logger,
            IJobGroupService jobGroupService
            )
        {
            this.logger = logger;
            this.jobGroupService = jobGroupService;
        }
        public async Task<bool> IsValidJobGroupAsync(Guid jobGroupId)
        {
            var isExist = await jobGroupService.GetAsync(jobGroupId);

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

            return true;
        }
    }
}
