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

namespace PARR.TemplateMatcher.Services.Implementations
{
    internal class JobGroupValidatorService : IJobGroupValidatorService
    {
        private readonly ILogger<IJobValidatorService> _logger;
        private readonly IJobGroupRepository _jobGroupService;

        public JobGroupValidatorService(
            ILogger<IJobValidatorService> logger,
            IJobGroupRepository jobGroupService
            )
        {
            _logger = logger;
            _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;
        }
    }
}
