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

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

        public JobGroupValidatorService(
            ILogger<IJobValidatorService> logger,
            IJobGroupRepository 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;
        }
    }
}
