public string GenerateUpdateJsonFromObject(PersonFollowUp 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(@"follow_up"); writer.WriteStartObject(); if (!FollowUpDate.Equals(updateFrom.FollowUpDate)) { writer.WritePropertyName("follow_date"); writer.WriteValue(updateFrom.FollowUpDate); } if (!HaveJobReturningTo.Equals(updateFrom.HaveJobReturningTo)) { writer.WritePropertyName("have_job_returning_to"); writer.WriteValue(updateFrom.HaveJobReturningTo); } if (!HoursWorked.Equals(updateFrom.HoursWorked)) { writer.WritePropertyName("hours_worked"); writer.WriteValue(updateFrom.HoursWorked); } if (!HouseWorkedOnHousework.Equals(updateFrom.HouseWorkedOnHousework)) { writer.WritePropertyName("hours_worked_on_housework"); writer.WriteValue(updateFrom.HouseWorkedOnHousework); } if (!EnrolledInSchool.Equals(updateFrom.EnrolledInSchool)) { writer.WritePropertyName("enrolled_in_school"); writer.WriteValue(updateFrom.EnrolledInSchool); } if (!GpsLatitude.Equals(updateFrom.GpsLatitude)) { writer.WritePropertyName("latitude"); writer.WriteValue(updateFrom.GpsLatitude); } if (!GpsLongitude.Equals(updateFrom.GpsLongitude)) { writer.WritePropertyName("longitude"); writer.WriteValue(updateFrom.GpsLongitude); } if (!GpsPositionAccuracy.Equals(updateFrom.GpsPositionAccuracy)) { writer.WritePropertyName("position_accuracy"); writer.WriteValue(updateFrom.GpsPositionAccuracy); } if (!GpsAltitude.Equals(updateFrom.GpsAltitude)) { writer.WritePropertyName("altitude"); writer.WriteValue(updateFrom.GpsAltitude); } if (!GpsAltitudeAccuracy.Equals(updateFrom.GpsAltitudeAccuracy)) { writer.WritePropertyName("altitude_accuracy"); writer.WriteValue(updateFrom.GpsAltitudeAccuracy); } if (!GpsHeading.Equals(updateFrom.GpsHeading)) { writer.WritePropertyName("heading"); writer.WriteValue(updateFrom.GpsHeading); } if (!GpsSpeed.Equals(updateFrom.GpsSpeed)) { writer.WritePropertyName("speed"); writer.WriteValue(updateFrom.GpsSpeed); } if (!GpsPositionTime.Equals(updateFrom.GpsPositionTime)) { writer.WritePropertyName("gps_recorded_at"); writer.WriteValue(updateFrom.GpsPositionTime); } if (!PeopleFollowUpHazardousConditions.Select(a => a.HazardousCondition).SequenceEqual(updateFrom.PeopleFollowUpHazardousConditions.Select(a => a.HazardousCondition))) { writer.WritePropertyName("hazardous_condition_ids"); writer.WriteRawValue(GetStatusArrayAsJsonString(PeopleFollowUpHazardousConditions.Select(a => a.HazardousCondition))); } if (!PeopleFollowUpWorkActivities.Select(a => a.WorkActivity).SequenceEqual(updateFrom.PeopleFollowUpWorkActivities.Select(a => a.WorkActivity))) { writer.WritePropertyName("work_activity_ids"); writer.WriteRawValue(GetStatusArrayAsJsonString(PeopleFollowUpWorkActivities.Select(a => a.WorkActivity))); } if (!PeopleFollowUpHouseholdTasks.Select(a => a.HouseholdTask).SequenceEqual(updateFrom.PeopleFollowUpHouseholdTasks.Select(a => a.HouseholdTask))) { writer.WritePropertyName("household_task_ids"); writer.WriteRawValue(GetStatusArrayAsJsonString(PeopleFollowUpHouseholdTasks.Select(a => a.HouseholdTask))); } if (!ExternalParentId.Equals(updateFrom.ExternalParentId)) { writer.WritePropertyName("person_id"); writer.WriteValue(updateFrom.ExternalParentId); } writer.WriteEndObject(); writer.WriteEndObject(); return(sw.ToString()); }
public bool GetObjectNeedsUpate(PersonFollowUp checkUpdateFrom) { if (!FollowUpDate.Equals(checkUpdateFrom.FollowUpDate)) { return(true); } if (!HaveJobReturningTo.Equals(checkUpdateFrom.HaveJobReturningTo)) { return(true); } if (!HoursWorked.Equals(checkUpdateFrom.HoursWorked)) { return(true); } if (!HouseWorkedOnHousework.Equals(checkUpdateFrom.HouseWorkedOnHousework)) { return(true); } if (!EnrolledInSchool.Equals(checkUpdateFrom.EnrolledInSchool)) { 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); } if (!PeopleFollowUpHazardousConditions.Select(a => a.HazardousCondition).SequenceEqual(checkUpdateFrom.PeopleFollowUpHazardousConditions.Select(a => a.HazardousCondition))) { return(true); } if (!PeopleFollowUpWorkActivities.Select(a => a.WorkActivity).SequenceEqual(checkUpdateFrom.PeopleFollowUpWorkActivities.Select(a => a.WorkActivity))) { return(true); } if (!PeopleFollowUpHouseholdTasks.Select(a => a.HouseholdTask).SequenceEqual(checkUpdateFrom.PeopleFollowUpHouseholdTasks.Select(a => a.HouseholdTask))) { return(true); } if (!ExternalParentId.Equals(checkUpdateFrom.ExternalParentId)) { return(true); } return(false); }
public string GenerateUpdateJsonFromObject(Person 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(@"person"); writer.WriteStartObject(); if (!LastName.Equals(updateFrom.LastName)) { writer.WritePropertyName("last_name"); writer.WriteValue(updateFrom.LastName); } if (!FirstName.Equals(updateFrom.FirstName)) { writer.WritePropertyName("first_name"); writer.WriteValue(updateFrom.FirstName); } if (!MiddleName.Equals(updateFrom.MiddleName)) { writer.WritePropertyName("middle_name"); writer.WriteValue(updateFrom.MiddleName); } if (!Gender.Equals(updateFrom.Gender)) { writer.WritePropertyName("sex"); writer.WriteValue(updateFrom.Gender); } if (!DateOfBirth.Equals(updateFrom.DateOfBirth)) { writer.WritePropertyName("dob"); writer.WriteValue(updateFrom.DateOfBirth); } if (!DateOfBirthIsApproximate.Equals(updateFrom.DateOfBirthIsApproximate)) { writer.WritePropertyName("is_birthdate_approximate"); writer.WriteValue(updateFrom.DateOfBirthIsApproximate); } if (!RelationshipToHeadOfHousehold.Equals(updateFrom.RelationshipToHeadOfHousehold)) { writer.WritePropertyName("relationship_id"); writer.WriteValue(updateFrom.RelationshipToHeadOfHousehold.ExternalId); } if (!RelationshipIfOther.Equals(updateFrom.RelationshipIfOther)) { writer.WritePropertyName("relationship_other"); writer.WriteValue(updateFrom.RelationshipIfOther); } if (!IntakeDate.Equals(updateFrom.IntakeDate)) { writer.WritePropertyName("intake_date"); writer.WriteValue(updateFrom.IntakeDate); } if (!HaveJobReturningTo.Equals(updateFrom.HaveJobReturningTo)) { writer.WritePropertyName("have_job_returning_to"); writer.WriteValue(updateFrom.HaveJobReturningTo); } if (!HoursWorked.Equals(updateFrom.HoursWorked)) { writer.WritePropertyName("hours_worked"); writer.WriteValue(updateFrom.HoursWorked); } if (!HouseWorkedOnHousework.Equals(updateFrom.HouseWorkedOnHousework)) { writer.WritePropertyName("hours_worked_on_housework"); writer.WriteValue(updateFrom.HouseWorkedOnHousework); } if (!EnrolledInSchool.Equals(updateFrom.EnrolledInSchool)) { writer.WritePropertyName("enrolled_in_school"); writer.WriteValue(updateFrom.EnrolledInSchool); } if (!GpsLatitude.Equals(updateFrom.GpsLatitude)) { writer.WritePropertyName("latitude"); writer.WriteValue(updateFrom.GpsLatitude); } if (!GpsLongitude.Equals(updateFrom.GpsLongitude)) { writer.WritePropertyName("longitude"); writer.WriteValue(updateFrom.GpsLongitude); } if (!GpsPositionAccuracy.Equals(updateFrom.GpsPositionAccuracy)) { writer.WritePropertyName("position_accuracy"); writer.WriteValue(updateFrom.GpsPositionAccuracy); } if (!GpsAltitude.Equals(updateFrom.GpsAltitude)) { writer.WritePropertyName("altitude"); writer.WriteValue(updateFrom.GpsAltitude); } if (!GpsAltitudeAccuracy.Equals(updateFrom.GpsAltitudeAccuracy)) { writer.WritePropertyName("altitude_accuracy"); writer.WriteValue(updateFrom.GpsAltitudeAccuracy); } if (!GpsHeading.Equals(updateFrom.GpsHeading)) { writer.WritePropertyName("heading"); writer.WriteValue(updateFrom.GpsHeading); } if (!GpsSpeed.Equals(updateFrom.GpsSpeed)) { writer.WritePropertyName("speed"); writer.WriteValue(updateFrom.GpsSpeed); } if (!GpsPositionTime.Equals(updateFrom.GpsPositionTime)) { writer.WritePropertyName("gps_recorded_at"); writer.WriteValue(updateFrom.GpsPositionTime); } if (!PeopleHazardousConditions.Select(a => a.HazardousCondition).SequenceEqual(updateFrom.PeopleHazardousConditions.Select(a => a.HazardousCondition))) { writer.WritePropertyName("hazardous_condition_ids"); writer.WriteRawValue(GetStatusArrayAsJsonString(PeopleHazardousConditions.Select(a => a.HazardousCondition))); } if (!PeopleWorkActivities.Select(a => a.WorkActivity).SequenceEqual(updateFrom.PeopleWorkActivities.Select(a => a.WorkActivity))) { writer.WritePropertyName("work_activity_ids"); writer.WriteRawValue(GetStatusArrayAsJsonString(PeopleWorkActivities.Select(a => a.WorkActivity))); } if (!PeopleHouseholdTasks.Select(a => a.HouseholdTask).SequenceEqual(updateFrom.PeopleHouseholdTasks.Select(a => a.HouseholdTask))) { writer.WritePropertyName("household_task_ids"); writer.WriteRawValue(GetStatusArrayAsJsonString(PeopleHouseholdTasks.Select(a => a.HouseholdTask))); } if (!ExternalParentId.Equals(updateFrom.ExternalParentId)) { writer.WritePropertyName("household_id"); writer.WriteValue(updateFrom.ExternalParentId); } writer.WriteEndObject(); writer.WriteEndObject(); return(sw.ToString()); }
public bool GetObjectNeedsUpate(Person checkUpdateFrom) { if (!LastName.Equals(checkUpdateFrom.LastName)) { return(true); } if (!FirstName.Equals(checkUpdateFrom.FirstName)) { return(true); } if (!MiddleName.Equals(checkUpdateFrom.MiddleName)) { return(true); } if (!Gender.Equals(checkUpdateFrom.Gender)) { return(true); } if (!DateOfBirth.Equals(checkUpdateFrom.DateOfBirth)) { return(true); } if (!DateOfBirthIsApproximate.Equals(checkUpdateFrom.DateOfBirthIsApproximate)) { return(true); } if (!RelationshipToHeadOfHousehold.Equals(checkUpdateFrom.RelationshipToHeadOfHousehold)) { return(true); } if (!RelationshipIfOther.Equals(checkUpdateFrom.RelationshipIfOther)) { return(true); } if (!IntakeDate.Equals(checkUpdateFrom.IntakeDate)) { return(true); } if (!HaveJobReturningTo.Equals(checkUpdateFrom.HaveJobReturningTo)) { return(true); } if (!HoursWorked.Equals(checkUpdateFrom.HoursWorked)) { return(true); } if (!HouseWorkedOnHousework.Equals(checkUpdateFrom.HouseWorkedOnHousework)) { return(true); } if (!EnrolledInSchool.Equals(checkUpdateFrom.EnrolledInSchool)) { 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); } if (!PeopleHazardousConditions.Select(a => a.HazardousCondition).SequenceEqual(checkUpdateFrom.PeopleHazardousConditions.Select(a => a.HazardousCondition))) { return(true); } if (!PeopleWorkActivities.Select(a => a.WorkActivity).SequenceEqual(checkUpdateFrom.PeopleWorkActivities.Select(a => a.WorkActivity))) { return(true); } if (!PeopleHouseholdTasks.Select(a => a.HouseholdTask).SequenceEqual(checkUpdateFrom.PeopleHouseholdTasks.Select(a => a.HouseholdTask))) { return(true); } if (!ExternalParentId.Equals(checkUpdateFrom.ExternalParentId)) { return(true); } return(false); }
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); }