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 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(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 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); }