/// <summary> /// Checks if service model is valid or not. /// </summary> public override void Validate(ModelStateDictionary modelState) { // Validate names names.Validate(modelState); // Validate all required descriptions descriptions = new LanguageItemListValidator(Model.ServiceCollectionDescriptions, "ServiceCollectionDescriptions", newLanguages); if (descriptions != null) { descriptions.Validate(modelState); } // Validate publishing status status.Validate(modelState); // Validate services if (services != null) { services.Validate(modelState); } // Validate main organization (must be user organization) mainOrganization.Validate(modelState); }
/// <summary> /// Ctor - service collection validator /// </summary> /// <param name="model">Service model</param> /// <param name="commonService">Common service</param> /// <param name="serviceService">Service service</param> /// <param name="newLanguages">Languages that should be validated within lists</param> /// <param name="userOrganizations">List of user organizations</param> public ServiceCollectionValidator( IVmOpenApiServiceCollectionInVersionBase model, ICommonService commonService, IServiceService serviceService, IList <string> newLanguages, IList <Guid> userOrganizations ) : base(model, "ServiceCollection") { if (model == null) { throw new ArgumentNullException(PropertyName, $"{PropertyName} must be defined."); } names = new LanguageItemListValidator(model.ServiceCollectionNames, "ServiceCollectionNames", newLanguages); status = new PublishingStatusValidator(model.PublishingStatus, model.CurrentPublishingStatus); mainOrganization = new UserOrganizationIdValidator(model.MainResponsibleOrganization, commonService, userOrganizations, "MainResponsibleOrganization"); // Validate service ids if (model.ServiceCollectionServices != null) { services = new ServiceIdListValidator(model.ServiceCollectionServices.ToList(), serviceService, "Services"); } this.newLanguages = newLanguages; }
/// <summary> /// Checks if electronic channel model is valid or not. /// </summary> /// <param name="modelState"></param> public override void Validate(ModelStateDictionary modelState) { // Validate names against newly added languages (required languages) var names = new LanguageItemListValidator(Model.ServiceChannelNames, "ServiceChannelNames", requiredLanguages); names.Validate(modelState); // Validate descriptions against newly added languages (required languages), all the available languages does not need to be validated. var descriptions = new LocalizedListValidator(Model.ServiceChannelDescriptions, "ServiceChannelDescriptions", requiredLanguages, new List <string>() { DescriptionTypeEnum.ShortDescription.ToString(), DescriptionTypeEnum.Description.ToString() }); descriptions.Validate(modelState); hours.Validate(modelState); organizationId.Validate(modelState); languages.Validate(modelState); phones.Validate(modelState); // Validate publishing status var status = new PublishingStatusValidator(Model.PublishingStatus, currentPublishingStatus); status.Validate(modelState); areas.Validate(modelState); services.Validate(modelState); }
/// <summary> /// Validates electronic channel model. /// </summary> /// <param name="modelState"></param> public override void Validate(ModelStateDictionary modelState) { base.Validate(modelState); // Url list need to contain required language items urls = new LanguageItemListValidator(Model.Urls, "Urls", RequiredLanguages); urls.Validate(modelState); }
/// <summary> /// Validates web page channel model. /// </summary> /// <param name="modelState"></param> public override void Validate(ModelStateDictionary modelState) { base.Validate(modelState); // Validate required urls property var urls = new LanguageItemListValidator(Model.Urls, "Urls", RequiredLanguages); urls.Validate(modelState); }