Ejemplo n.º 1
0
 /// <summary>
 /// Ctor - printable form channel validator
 /// </summary>
 /// <param name="model">printable form channel model</param>
 /// <param name="commonService">Common service</param>
 /// <param name="codeService">Code service</param>
 /// <param name="serviceService">Service service</param>
 public PrintableFormChannelValidator(VmOpenApiPrintableFormChannelInVersionBase model, ICommonService commonService, ICodeService codeService, IServiceService serviceService) :
     base(model, "PrintableFormChannel", commonService, codeService, serviceService)
 {
     address = new AddressValidator(model.DeliveryAddress == null ? null : new V7VmOpenApiAddressInVersionBase
     {
         SubType       = model.DeliveryAddress.SubType,
         StreetAddress = (model.DeliveryAddress.SubType == AddressTypeEnum.Street.ToString() && model.DeliveryAddress.StreetAddress != null) ?
                         new VmOpenApiAddressStreetWithCoordinatesIn
         {
             PostalCode   = model.DeliveryAddress.StreetAddress.PostalCode,
             Municipality = model.DeliveryAddress.StreetAddress.Municipality
         } : null,
         PostOfficeBoxAddress = (model.DeliveryAddress.SubType == AddressTypeEnum.PostOfficeBox.ToString() && model.DeliveryAddress.PostOfficeBoxAddress != null) ?
                                new VmOpenApiAddressPostOfficeBoxIn
         {
             PostalCode   = model.DeliveryAddress.PostOfficeBoxAddress.PostalCode,
             Municipality = model.DeliveryAddress.PostOfficeBoxAddress.Municipality
         } : null
     }, "DeliveryAddress", codeService);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Checks if address list is valid or not.
        /// </summary>
        /// <param name="modelState"></param>
        public override void Validate(ModelStateDictionary modelState)
        {
            if (Model == null)
            {
                return;
            }

            var i = 0;

            Model.ForEach(a =>
            {
                if (a != null)
                {
                    var address = new AddressValidator(a, $"{PropertyName}[{ i }]", codeService);
                    address.Validate(modelState);
                    // Validate country code
                    var country = new CountryCodeValidator(a.Country, codeService, $"{PropertyName}[{ i }].Country");
                    country.Validate(modelState);
                }
                i++;
            });
        }