コード例 #1
0
        /// <summary>
        /// Ctor - service validator
        /// </summary>
        /// <param name="model">Service model</param>
        /// <param name="generalDescriptionService">General description service</param>
        /// <param name="codeService">Code service</param>
        /// <param name="fintoService">Finto item service</param>
        /// <param name="commonService">Common service</param>
        /// <param name="channelService">Channel service</param>
        /// <param name="newLanguages">Languages that should be validated within lists</param>
        /// <param name="userRole">User role</param>
        public ServiceValidator(
            IVmOpenApiServiceInVersionBase model,
            IGeneralDescriptionService generalDescriptionService,
            ICodeService codeService,
            IFintoService fintoService,
            ICommonService commonService,
            IChannelService channelService,
            IList <string> newLanguages,
            UserRoleEnum userRole
            ) : base(model, "Service")
        {
            this.generalDescriptionService = generalDescriptionService;

            if (model == null)
            {
                throw new ArgumentNullException(PropertyName, $"{PropertyName} must be defined.");
            }

            names = new LocalizedListValidator(model.ServiceNames, "ServiceNames", newLanguages, new List <string>()
            {
                NameTypeEnum.Name.ToString()
            });
            languages         = new LanguageListValidator(model.Languages, codeService);
            serviceClasses    = new ServiceClassListValidator(model.ServiceClasses, fintoService);
            ontologyTerms     = new OntologyTermListValidator(model.OntologyTerms, fintoService);
            targetGroups      = new TargetGroupListValidator(model.TargetGroups, fintoService);
            lifeEvents        = new LifeEventListValidator(model.LifeEvents, fintoService);
            industrialClasses = new IndustrialClassListValidator(model.IndustrialClasses, fintoService);
            organizations     = new OrganizationIdListValidator(model.OtherResponsibleOrganizations?.Select(o => o.ToString()).ToList(), commonService, "OtherResponsibleOrganizations");
            status            = new PublishingStatusValidator(model.PublishingStatus, model.CurrentPublishingStatus);
            areas             = new AreaAndTypeValidator(model.Areas, model.AreaType, codeService);
            var channelList = model.ServiceServiceChannels?.Count > 0 ? model.ServiceServiceChannels.Select(i => i.ChannelGuid).ToList() : new List <Guid>();

            channels = new ServiceChannelIdListValidator(channelList, channelService, userRole, "ServiceChannels");

            var availableOrganizations = new List <Guid>();

            if (!model.MainResponsibleOrganization.IsNullOrEmpty())
            {
                availableOrganizations.Add(model.MainResponsibleOrganization.ParseToGuidWithExeption());
            }
            if (model.OtherResponsibleOrganizations?.Count > 0)
            {
                availableOrganizations.AddRange(model.OtherResponsibleOrganizations);
            }
            serviceProducers = new ServiceProducerListValidator(model.ServiceProducers, availableOrganizations, commonService);

            mainOrganization = new OrganizationIdValidator(model.MainResponsibleOrganization, commonService, "MainResponsibleOrganization");

            generalDescriptionAttached = !string.IsNullOrEmpty(model.StatutoryServiceGeneralDescriptionId);
            this.newLanguages          = newLanguages;
        }
コード例 #2
0
        /// <summary>
        /// Ctor - general description validator
        /// </summary>
        /// <param name="model">General description model</param>
        /// <param name="codeService">Code service</param>
        /// <param name="fintoService">Finto item service</param>
        /// <param name="newLanguages">Languages that should be validated within lists</param>
        /// <param name="createOperation">Indicates if general description is beeing created or updated.</param>
        public GeneralDescriptionValidator(IVmOpenApiGeneralDescriptionInVersionBase model, ICodeService codeService, IFintoService fintoService, IList <string> newLanguages, bool createOperation)
            : base(model, "GeneralDescription")
        {
            if (model == null)
            {
                throw new ArgumentNullException(PropertyName, $"{PropertyName} must be defined.");
            }

            names = new LocalizedListValidator(model.Names, "Names", newLanguages, new List <string>()
            {
                NameTypeEnum.Name.ToString()
            });
            languages         = new LanguageListValidator(model.Languages, codeService);
            serviceClasses    = new ServiceClassListValidator(model.ServiceClasses, fintoService);
            ontologyTerms     = new OntologyTermListValidator(model.OntologyTerms, fintoService);
            targetGroups      = new TargetGroupListValidator(model.TargetGroups, fintoService);
            lifeEvents        = new LifeEventListValidator(model.LifeEvents, fintoService);
            industrialClasses = new IndustrialClassListValidator(model.IndustrialClasses, fintoService);
            status            = new PublishingStatusValidator(model.PublishingStatus, model.CurrentPublishingStatus);

            this.createOperation = createOperation;
            this.newLanguages    = newLanguages;
        }