using NetworkResurrector.Agent.Application.Services.Abstractions;
using NetworkResurrector.Agent.Domain.Errors;
using NetworkResurrector.Agent.PublishedLanguage.Dto;
using System;

namespace NetworkResurrector.Agent.Application.Services
{
    internal class ValidationService : IValidationService
    {
        private readonly IParamProvider _paramProvider;

        public ValidationService(IParamProvider paramProvider)
        {
            _paramProvider=paramProvider;
        }

        public void ValidateRestrictions(ActionOwner actionOwner)
        {
            if (_paramProvider.Restrictions.EnforceActionOwner && (actionOwner == null || string.IsNullOrWhiteSpace(actionOwner.OwnerCode)))
                throw new Exception(Errors.ACTION_OWNER_NOT_SPECIFIED.Code);
        }
    }
}
