/// <summary>
 /// Ctor - service location channel validator
 /// </summary>
 /// <param name="model">service location channel model</param>
 /// <param name="commonService">Common service</param>
 /// <param name="codeService">Code service</param>
 /// <param name="serviceService">Service service</param>
 public ServiceLocationChannelValidator(VmOpenApiServiceLocationChannelInVersionBase model, ICommonService commonService, ICodeService codeService, IServiceService serviceService) :
     base(model, "ServiceLocationChannel", commonService, codeService, serviceService)
 {
     phones     = new PhoneNumberListValidator <V4VmOpenApiPhone>(model.PhoneNumbers, codeService);
     faxNumbers = new PhoneNumberListValidator <V4VmOpenApiPhoneSimple>(model.FaxNumbers, codeService, "FaxNumbers");
     addresses  = new AddressListValidator <V7VmOpenApiAddressWithMovingIn>(model.Addresses, codeService);
 }
Пример #2
0
        /// <summary>
        /// Ctor - organization validator
        /// </summary>
        /// <param name="model">Organization model</param>
        /// <param name="codeService">Code service</param>
        /// <param name="organizationService">Organization service</param>
        /// <param name="commonService">Common service</param>
        /// <param name="newLanguages">Languages that should be validated within lists</param>
        /// <param name="availableLanguages">The languages that are available in main model and therefore need to be validated.</param>
        /// <param name="isCreateOperation">Indicates if organization is beeing inserted or updated.</param>
        /// <param name="versionNumber">Version number.</param>
        public OrganizationValidator(IVmOpenApiOrganizationInVersionBase model, ICodeService codeService, IOrganizationService organizationService, IList <string> newLanguages, IList <string> availableLanguages, ICommonService commonService, int versionNumber, bool isCreateOperation = false)
            : base(model, "Organization")
        {
            this.codeService = codeService;

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

            name = new LocalizedListValidator(model.OrganizationNames, "OrganizationNames", newLanguages, new List <string>()
            {
                NameTypeEnum.Name.ToString()
            });
            municipality   = new MunicipalityCodeValidator(model.Municipality, codeService);
            addresses      = new AddressListValidator <V7VmOpenApiAddressWithForeignIn>(model.Addresses, codeService);
            organizationId = new OrganizationIdValidator(model.ParentOrganizationId, commonService, "ParentOrganizationId");
            oid            = new OidValidator(model.Oid, organizationService, isCreateOperation: isCreateOperation, organizationId: model.Id, sourceId: model.SourceId);
            phones         = new PhoneNumberListValidator <V4VmOpenApiPhone>(model.PhoneNumbers, codeService);
            status         = new PublishingStatusValidator(model.PublishingStatus, model.CurrentPublishingStatus);
            description    = new LocalizedListValidator(model.OrganizationDescriptions, "OrganizationDescriptions", newLanguages, new List <string>()
            {
                DescriptionTypeEnum.ShortDescription.ToString()
            }, availableLanguages);
            this.versionNumber = versionNumber;
        }
Пример #3
0
        /// <summary>
        /// Validates phone channel model.
        /// </summary>
        /// <param name="modelState"></param>
        public override void Validate(ModelStateDictionary modelState)
        {
            base.Validate(modelState);

            // Validate phone numbers
            var phones = new PhoneNumberListValidator <V4VmOpenApiPhoneWithType>(Model.PhoneNumbers, codeService, requiredLanguages: RequiredLanguages, availableLanguages: AvailableLanguages);

            phones.Validate(modelState);
        }
Пример #4
0
        /// <summary>
        /// Ctor - channel validator
        /// </summary>
        /// <param name="model"></param>
        /// <param name="propertyName">Property name</param>
        /// <param name="commonService">Common service</param>
        /// <param name="codeService">Code service</param>
        /// <param name="serviceService">Service service</param>
        public ServiceChannelValidator(TModel model, string propertyName, ICommonService commonService, ICodeService codeService, IServiceService serviceService)
            : base(model, propertyName)
        {
            if (model == null)
            {
                throw new ArgumentNullException(PropertyName, $"{PropertyName} must be defined.");
            }

            this.codeService   = codeService;
            requiredLanguages  = new List <string>();
            availableLanguages = new List <string>();

            hours          = new ServiceHourListValidator <V4VmOpenApiServiceHour>(model.ServiceHours);
            organizationId = new OrganizationIdValidator(model.OrganizationId, commonService);
            languages      = new LanguageListValidator(model.Languages, codeService);
            phones         = new PhoneNumberListValidator <V4VmOpenApiPhone>(model.SupportPhones, codeService); // Support phone property is not required so no need to check language items (required/available languages)
            areas          = new AreaAndTypeValidator(model.Areas, model.AreaType, codeService);
            services       = new ServiceIdListValidator(model.ServiceChannelServices.ToList(), serviceService, "Services");
        }