public bool Equals(ICityStateZipData other)
 {
     return(City.Equals(other.City, StringComparison.CurrentCultureIgnoreCase) &&
            StateName.Equals(other.StateName, StringComparison.CurrentCultureIgnoreCase) &&
            StateAbbreviation.Equals(other.StateAbbreviation, StringComparison.CurrentCultureIgnoreCase) &&
            ZipCode.Equals(other.ZipCode, StringComparison.CurrentCultureIgnoreCase));
 }
Example #2
0
        /// <summary>
        /// Performs model validation. A model is invalid if has any error
        /// after a validation. Therefore, if there is any invalid
        /// model property, the implementation must specify a error by
        /// adding a new error using 'AddError' method
        /// </summary>
        protected override void PerformValidation()
        {
            if (!StateAbbreviation.NotNullOrEmpty())
            {
                AddError(nameof(StateAbbreviation), ErrorCodes.StateAbbreviationRequired, "State Abbreviation is required");
            }

            if (!City.NotNullOrEmpty())
            {
                AddError(nameof(City), ErrorCodes.CityRequired, "City is required");
            }

            if (!StreetName.NotNullOrEmpty())
            {
                AddError(nameof(StreetName), ErrorCodes.StreetNameRequired, "Street name is required");
            }

            if (!StateAbbreviation.HasLength(2))
            {
                AddError(nameof(StateAbbreviation), ErrorCodes.StateAbbreviationInvalidLength, "State Abbreviation length must be 2");
            }

            if (!City.HasMinLength(3))
            {
                AddError(nameof(City), ErrorCodes.CityInvalidLength, "City length must be at least 3");
            }

            if (!StreetName.HasMinLength(3))
            {
                AddError(nameof(StreetName), ErrorCodes.StreetNameInvalidLength, "Street name length must be at least 3");
            }
        }
Example #3
0
 public Address(string addressLine1, string addressLine2, string city, StateAbbreviation state, string zipCode)
 {
     AddressLine1 = addressLine1;
     AddressLine2 = addressLine2;
     City         = city;
     State        = state;
     ZipCode      = zipCode;
 }
Example #4
0
 public override int GetHashCode()
 {
     return(Name.GetHashCode()
            ^ StateAbbreviation.GetHashCode()
            ^ StateName.GetHashCode()
            ^ Id.GetHashCode()
            ^ Latitude.GetHashCode()
            ^ Longitude.GetHashCode());
 }
Example #5
0
        public IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
        {
            List <ValidationResult> errors = new List <ValidationResult>();

            if (string.IsNullOrEmpty(StateName) || string.IsNullOrEmpty(StateAbbreviation))
            {
                errors.Add(new ValidationResult("Please enter a state name and abbreviation!", new[] { "StateName", "StateAbbreviation" }));
            }
            else if (StateAbbreviation.Any(Char.IsDigit) || StateAbbreviation.Length > 2)
            {
                errors.Add(new ValidationResult("Please enter a valid State Abbreviation", new[] { "StateAbbreviation" }));
            }

            return(errors);
        }
 public Address(StateAbbreviation state)
 {
     State = state;
 }