Exemple #1
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }

            if (obj == this)
            {
                return(true);
            }

            return(obj is Address other &&
                   ((AddressLine1 == null && other.AddressLine1 == null) || (AddressLine1?.Equals(other.AddressLine1) == true)) &&
                   ((AddressLine2 == null && other.AddressLine2 == null) || (AddressLine2?.Equals(other.AddressLine2) == true)) &&
                   ((AddressLine3 == null && other.AddressLine3 == null) || (AddressLine3?.Equals(other.AddressLine3) == true)) &&
                   ((Locality == null && other.Locality == null) || (Locality?.Equals(other.Locality) == true)) &&
                   ((Sublocality == null && other.Sublocality == null) || (Sublocality?.Equals(other.Sublocality) == true)) &&
                   ((Sublocality2 == null && other.Sublocality2 == null) || (Sublocality2?.Equals(other.Sublocality2) == true)) &&
                   ((Sublocality3 == null && other.Sublocality3 == null) || (Sublocality3?.Equals(other.Sublocality3) == true)) &&
                   ((AdministrativeDistrictLevel1 == null && other.AdministrativeDistrictLevel1 == null) || (AdministrativeDistrictLevel1?.Equals(other.AdministrativeDistrictLevel1) == true)) &&
                   ((AdministrativeDistrictLevel2 == null && other.AdministrativeDistrictLevel2 == null) || (AdministrativeDistrictLevel2?.Equals(other.AdministrativeDistrictLevel2) == true)) &&
                   ((AdministrativeDistrictLevel3 == null && other.AdministrativeDistrictLevel3 == null) || (AdministrativeDistrictLevel3?.Equals(other.AdministrativeDistrictLevel3) == true)) &&
                   ((PostalCode == null && other.PostalCode == null) || (PostalCode?.Equals(other.PostalCode) == true)) &&
                   ((Country == null && other.Country == null) || (Country?.Equals(other.Country) == true)) &&
                   ((FirstName == null && other.FirstName == null) || (FirstName?.Equals(other.FirstName) == true)) &&
                   ((LastName == null && other.LastName == null) || (LastName?.Equals(other.LastName) == true)) &&
                   ((Organization == null && other.Organization == null) || (Organization?.Equals(other.Organization) == true)));
        }
        /// <summary>
        /// Returns true if PhysicalAddress instances are equal
        /// </summary>
        /// <param name="other">Instance of PhysicalAddress to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(PhysicalAddress other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     CountryId == other.CountryId ||
                     CountryId != null &&
                     CountryId.Equals(other.CountryId)
                     ) &&
                 (
                     Zip == other.Zip ||
                     Zip != null &&
                     Zip.Equals(other.Zip)
                 ) &&
                 (
                     City == other.City ||
                     City != null &&
                     City.Equals(other.City)
                 ) &&
                 (
                     AdministrativeArea == other.AdministrativeArea ||
                     AdministrativeArea != null &&
                     AdministrativeArea.Equals(other.AdministrativeArea)
                 ) &&
                 (
                     DependentLocality == other.DependentLocality ||
                     DependentLocality != null &&
                     DependentLocality.Equals(other.DependentLocality)
                 ) &&
                 (
                     SortingCode == other.SortingCode ||
                     SortingCode != null &&
                     SortingCode.Equals(other.SortingCode)
                 ) &&
                 (
                     Organization == other.Organization ||
                     Organization != null &&
                     Organization.Equals(other.Organization)
                 ) &&
                 (
                     AddressLine1 == other.AddressLine1 ||
                     AddressLine1 != null &&
                     AddressLine1.Equals(other.AddressLine1)
                 ) &&
                 (
                     AddressLine2 == other.AddressLine2 ||
                     AddressLine2 != null &&
                     AddressLine2.Equals(other.AddressLine2)
                 ));
        }
        /// <summary>
        /// Returns true if CommonSimpleAddress instances are equal
        /// </summary>
        /// <param name="other">Instance of CommonSimpleAddress to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(CommonSimpleAddress other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     MailingName == other.MailingName ||
                     MailingName != null &&
                     MailingName.Equals(other.MailingName)
                     ) &&
                 (
                     AddressLine1 == other.AddressLine1 ||
                     AddressLine1 != null &&
                     AddressLine1.Equals(other.AddressLine1)
                 ) &&
                 (
                     AddressLine2 == other.AddressLine2 ||
                     AddressLine2 != null &&
                     AddressLine2.Equals(other.AddressLine2)
                 ) &&
                 (
                     AddressLine3 == other.AddressLine3 ||
                     AddressLine3 != null &&
                     AddressLine3.Equals(other.AddressLine3)
                 ) &&
                 (
                     Postcode == other.Postcode ||
                     Postcode != null &&
                     Postcode.Equals(other.Postcode)
                 ) &&
                 (
                     City == other.City ||
                     City != null &&
                     City.Equals(other.City)
                 ) &&
                 (
                     State == other.State ||
                     State != null &&
                     State.Equals(other.State)
                 ) &&
                 (
                     Country == other.Country ||
                     Country != null &&
                     Country.Equals(other.Country)
                 ));
        }
Exemple #4
0
 public bool Equals(Address other)
 {
     if (other == null)
     {
         return(false);
     }
     return(AddressLine1.Equals(other.AddressLine1) &&
            ((AddressLine2 == null && other.AddressLine2 == null) ||
             (AddressLine2 != null && AddressLine2.Equals(other.AddressLine2))) &&
            PostalCode.Equals(other.PostalCode) &&
            City.Equals(other.City) &&
            Country.Equals(other.Country));
 }
Exemple #5
0
        /// <summary>
        /// Returns true if Address instances are equal
        /// </summary>
        /// <param name="other">Instance of Address to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(Address other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     AddressLine1 == other.AddressLine1 ||
                     AddressLine1 != null &&
                     AddressLine1.Equals(other.AddressLine1)
                     ) &&
                 (
                     AddressLine2 == other.AddressLine2 ||
                     AddressLine2 != null &&
                     AddressLine2.Equals(other.AddressLine2)
                 ) &&
                 (
                     City == other.City ||
                     City != null &&
                     City.Equals(other.City)
                 ) &&
                 (
                     State == other.State ||
                     State != null &&
                     State.Equals(other.State)
                 ) &&
                 (
                     Zip == other.Zip ||
                     Zip != null &&
                     Zip.Equals(other.Zip)
                 ) &&
                 (
                     Country == other.Country ||
                     Country != null &&
                     Country.Equals(other.Country)
                 ));
        }
Exemple #6
0
        public override bool Equals(object obj)
        {
            var respondent = obj as Respondent;

            if (respondent != null)
            {
                return(RespondentID.ToString().Equals(respondent.RespondentID.ToString(), StringComparison.Ordinal) &&
                       FirstName.Equals(respondent.FirstName) &&
                       LastName.Equals(respondent.LastName) &&
                       EmailAddress.Equals(respondent.EmailAddress) &&
                       AddressLine1.Equals(respondent.AddressLine1) &&
                       AddressLine2.Equals(respondent.AddressLine2) &&
                       City.Equals(respondent.City) &&
                       StateAbbr.Equals(respondent.StateAbbr) &&
                       ZipCode.Equals(respondent.ZipCode) &&
                       LastSurvey.Equals(respondent.LastSurvey));
            }

            return(false);
        }
Exemple #7
0
        /// <summary>
        /// Returns true if AddressesModel2 instances are equal
        /// </summary>
        /// <param name="other">Instance of AddressesModel2 to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(AddressesModel2 other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     AddressId == other.AddressId ||
                     AddressId != null &&
                     AddressId.Equals(other.AddressId)
                     ) &&
                 (
                     Nickname == other.Nickname ||
                     Nickname != null &&
                     Nickname.Equals(other.Nickname)
                 ) &&
                 (
                     CountryId == other.CountryId ||
                     CountryId != null &&
                     CountryId.Equals(other.CountryId)
                 ) &&
                 (
                     Zip == other.Zip ||
                     Zip != null &&
                     Zip.Equals(other.Zip)
                 ) &&
                 (
                     City == other.City ||
                     City != null &&
                     City.Equals(other.City)
                 ) &&
                 (
                     AdministrativeArea == other.AdministrativeArea ||
                     AdministrativeArea != null &&
                     AdministrativeArea.Equals(other.AdministrativeArea)
                 ) &&
                 (
                     DependentLocality == other.DependentLocality ||
                     DependentLocality != null &&
                     DependentLocality.Equals(other.DependentLocality)
                 ) &&
                 (
                     SortingCode == other.SortingCode ||
                     SortingCode != null &&
                     SortingCode.Equals(other.SortingCode)
                 ) &&
                 (
                     Organization == other.Organization ||
                     Organization != null &&
                     Organization.Equals(other.Organization)
                 ) &&
                 (
                     AddressLine1 == other.AddressLine1 ||
                     AddressLine1 != null &&
                     AddressLine1.Equals(other.AddressLine1)
                 ) &&
                 (
                     AddressLine2 == other.AddressLine2 ||
                     AddressLine2 != null &&
                     AddressLine2.Equals(other.AddressLine2)
                 ) &&
                 (
                     IsPrimary == other.IsPrimary ||
                     IsPrimary != null &&
                     IsPrimary.Equals(other.IsPrimary)
                 ) &&
                 (
                     SessionToken == other.SessionToken ||
                     SessionToken != null &&
                     SessionToken.Equals(other.SessionToken)
                 ));
        }
        public string GenerateUpdateJsonFromObject(Household updateFrom)
        {
            // form the json (determine the fields that need to be updated)
            var sb     = new StringBuilder();
            var sw     = new StringWriter(sb);
            var writer = new JsonTextWriter(sw)
            {
                Formatting = Formatting.None
            };

            writer.WriteStartObject();
            writer.WritePropertyName(@"household");
            writer.WriteStartObject();

            if (!HouseholdName.Equals(updateFrom.HouseholdName))
            {
                writer.WritePropertyName("name");
                writer.WriteValue(updateFrom.HouseholdName);
            }

            if (!IntakeDate.Equals(updateFrom.IntakeDate))
            {
                writer.WritePropertyName("intake_date");
                writer.WriteValue(updateFrom.IntakeDate.ToString("yyyy-MM-dd"));
            }

            if (!AddressLine1.Equals(updateFrom.AddressLine1))
            {
                writer.WritePropertyName("address_line_1");
                writer.WriteValue(updateFrom.AddressLine1);
            }

            if (!AddressLine2.Equals(updateFrom.AddressLine2))
            {
                writer.WritePropertyName("address_line_2");
                writer.WriteValue(updateFrom.AddressLine2);
            }

            if (!PostalCode.Equals(updateFrom.PostalCode))
            {
                writer.WritePropertyName("postal_code");
                writer.WriteValue(updateFrom.PostalCode);
            }

            if (!DependentLocality.Equals(updateFrom.DependentLocality))
            {
                writer.WritePropertyName("dependent_locality");
                writer.WriteValue(updateFrom.DependentLocality);
            }

            if (!Locality.Equals(updateFrom.Locality))
            {
                writer.WritePropertyName("locality");
                writer.WriteValue(updateFrom.Locality);
            }

            if (!AdminvArea.Equals(updateFrom.AdminvArea))
            {
                writer.WritePropertyName("adminv_area");
                writer.WriteValue(updateFrom.AdminvArea);
            }

            if (!DependentAdminvArea.Equals(updateFrom.DependentAdminvArea))
            {
                writer.WritePropertyName("dependent_adminv_area");
                writer.WriteValue(updateFrom.DependentAdminvArea);
            }

            if (!Country.Equals(updateFrom.Country))
            {
                writer.WritePropertyName("country");
                writer.WriteValue(updateFrom.Country);
            }

            if (!AddressInfo.Equals(updateFrom.AddressInfo))
            {
                writer.WritePropertyName("address_info");
                writer.WriteValue(updateFrom.AddressInfo);
            }

            if (!GpsLatitude.Equals(updateFrom.GpsLatitude))
            {
                writer.WritePropertyName("latitude");
                writer.WriteValue(updateFrom.GpsLatitude ?? null);
            }

            if (!GpsLongitude.Equals(updateFrom.GpsLongitude))
            {
                writer.WritePropertyName("longitude");
                writer.WriteValue(updateFrom.GpsLongitude ?? null);
            }

            if (!GpsPositionAccuracy.Equals(updateFrom.GpsPositionAccuracy))
            {
                writer.WritePropertyName("position_accuracy");
                writer.WriteValue(updateFrom.GpsPositionAccuracy ?? null);
            }

            if (!GpsAltitude.Equals(updateFrom.GpsAltitude))
            {
                writer.WritePropertyName("altitude");
                writer.WriteValue(updateFrom.GpsAltitude ?? null);
            }

            if (!GpsAltitudeAccuracy.Equals(updateFrom.GpsAltitudeAccuracy))
            {
                writer.WritePropertyName("altitude_accuracy");
                writer.WriteValue(updateFrom.GpsAltitudeAccuracy ?? null);
            }

            if (!GpsHeading.Equals(updateFrom.GpsHeading))
            {
                writer.WritePropertyName("heading");
                writer.WriteValue(updateFrom.GpsHeading ?? null);
            }

            if (!GpsSpeed.Equals(updateFrom.GpsSpeed))
            {
                writer.WritePropertyName("speed");
                writer.WriteValue(updateFrom.GpsSpeed ?? null);
            }

            if (!GpsPositionTime.Equals(updateFrom.GpsPositionTime))
            {
                writer.WritePropertyName("gps_recorded_at");
                writer.WriteValue(updateFrom.GpsPositionTime ?? null);
            }

            writer.WriteEndObject();
            writer.WriteEndObject();
            return(sw.ToString());
        }
 public bool GetObjectNeedsUpate(Household checkUpdateFrom)
 {
     if (!HouseholdName.Equals(checkUpdateFrom.HouseholdName))
     {
         return(true);
     }
     if (!IntakeDate.Equals(checkUpdateFrom.IntakeDate))
     {
         return(true);
     }
     if (!AddressLine1.Equals(checkUpdateFrom.AddressLine1))
     {
         return(true);
     }
     if (!AddressLine2.Equals(checkUpdateFrom.AddressLine2))
     {
         return(true);
     }
     if (!PostalCode.Equals(checkUpdateFrom.PostalCode))
     {
         return(true);
     }
     if (!DependentLocality.Equals(checkUpdateFrom.DependentLocality))
     {
         return(true);
     }
     if (!Locality.Equals(checkUpdateFrom.Locality))
     {
         return(true);
     }
     if (!AdminvArea.Equals(checkUpdateFrom.AdminvArea))
     {
         return(true);
     }
     if (!DependentAdminvArea.Equals(checkUpdateFrom.DependentAdminvArea))
     {
         return(true);
     }
     if (!Country.Equals(checkUpdateFrom.Country))
     {
         return(true);
     }
     if (!AddressInfo.Equals(checkUpdateFrom.AddressInfo))
     {
         return(true);
     }
     if (!GpsLatitude.Equals(checkUpdateFrom.GpsLatitude))
     {
         return(true);
     }
     if (!GpsLongitude.Equals(checkUpdateFrom.GpsLongitude))
     {
         return(true);
     }
     if (!GpsPositionAccuracy.Equals(checkUpdateFrom.GpsPositionAccuracy))
     {
         return(true);
     }
     if (!GpsAltitude.Equals(checkUpdateFrom.GpsAltitude))
     {
         return(true);
     }
     if (!GpsAltitudeAccuracy.Equals(checkUpdateFrom.GpsAltitudeAccuracy))
     {
         return(true);
     }
     if (!GpsHeading.Equals(checkUpdateFrom.GpsHeading))
     {
         return(true);
     }
     if (!GpsSpeed.Equals(checkUpdateFrom.GpsSpeed))
     {
         return(true);
     }
     if (!GpsPositionTime.Equals(checkUpdateFrom.GpsPositionTime))
     {
         return(true);
     }
     return(false);
 }