using Microsoft.EntityFrameworkCore; using PARR.DAL.Services.Interfaces.Job; using PARR.DAL.Services.Interfaces.Unit; namespace PARR.TemplateGeneratorWorker.Services { internal class ValidatorService : IValidatorService { private readonly ILogger logger; private readonly IJobService jobService; private readonly IUnitService unitService; public ValidatorService( ILogger logger, IJobService jobService, IUnitService unitService ) { this.logger = logger; this.jobService = jobService; this.unitService = unitService; } public async Task IsValidAsync(Guid jobId, Guid unitId) { var job = await jobService .Get().AsNoTracking() .FirstOrDefaultAsync(t => t.Id == jobId); if (job == null) { logger.LogError($"Не найдена регалментная работа {nameof(jobId)}: {jobId}"); return false; } var unit = await unitService .Get().AsNoTracking() .FirstOrDefaultAsync(t => t.Id == unitId); if (unit == null) { logger.LogError($"Не найден элемент конфигурации {nameof(unitId)}: {unitId}"); return false; } return true; } } }