示例#1
0
        /// <summary>
        /// Gets export validator.
        /// Create if need or use created.
        /// </summary>
        /// <returns>Export validator.</returns>
        private ExportValidator _GetExportValidator()
        {
            if (null == _exportValidator)
            {
                App app = App.Current;
                _exportValidator =
                    new ExportValidator(app.Project.CapacitiesInfo, app.Geocoder.AddressFields);
            }

            Debug.Assert(_exportValidator != null);
            return(_exportValidator);
        }
示例#2
0
        /// <summary>
        /// Performs validation of custom order property name.
        /// </summary>
        /// <param name="propertyName">Custom order property name.</param>
        /// <param name="errorMessage">Output parameter to store error message.
        /// If property name is valid this parameter is set to empty string.</param>
        /// <returns>True - if property name is valid, otherwise - false.</returns>
        public bool Validate(string propertyName, out string errorMessage)
        {
            bool validationResult = false;

            errorMessage = string.Empty;

            // If property name is empty.
            if (string.IsNullOrEmpty(propertyName))
            {
                validationResult = false;

                errorMessage = string.Format(Messages.Error_NullName,
                                             App.Current.GetString("CustomOrderProperty"));
            }
            // Property name is not empty, check it's uniqueness.
            else
            {
                // Get collection of custom order properties names.
                ICollection <string> names = _GetCurrentNamesCollection();

                // Check if collection contains only one item with given name.
                validationResult = _IsPropertyNameUnique(propertyName, names);

                if (validationResult)
                {
                    // Check that current name is not reserved.
                    ExportValidator exportValidator = _GetExportValidator();
                    validationResult =
                        exportValidator.IsCustomOrderFieldNameUnique(propertyName, names);

                    if (!validationResult)
                    {
                        // Name is reserved.
                        errorMessage = string.Format(Messages.Error_ReservedCustomOrderPropertyName,
                                                     App.Current.GetString("CustomOrderProperty"),
                                                     propertyName);
                    }
                }
                // Name is not unique in current collection.
                else
                {
                    errorMessage = string.Format(Messages.Error_DuplicateName,
                                                 App.Current.GetString("CustomOrderProperty"),
                                                 propertyName);
                }
            }

            return(validationResult);
        }