public string GenerateUpdateJsonFromObject(IncomeSource 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(@"income_source"); writer.WriteStartObject(); if (!ProductServiceName.Equals(updateFrom.ProductServiceName)) { writer.WritePropertyName("name"); writer.WriteValue(updateFrom.ProductServiceName ?? @""); } if (!EstimatedVolumeProduced.Equals(updateFrom.EstimatedVolumeProduced)) { writer.WritePropertyName("estimated_volume_produced"); writer.WriteValue(updateFrom.EstimatedVolumeProduced ?? null); } if (!EstimatedVolumeSold.Equals(updateFrom.EstimatedVolumeSold)) { writer.WritePropertyName("estimated_volume_sold"); writer.WriteValue(updateFrom.EstimatedVolumeSold ?? null); } if (!UnitOfMeasure.Equals(updateFrom.UnitOfMeasure)) { writer.WritePropertyName("unit_of_measure"); writer.WriteValue(updateFrom.UnitOfMeasure ?? @""); } if (!EstimatedIncome.Equals(updateFrom.EstimatedIncome)) { writer.WritePropertyName("estimated_income"); writer.WriteValue(updateFrom.EstimatedIncome ?? null); } if (!Currency.Equals(updateFrom.Currency)) { writer.WritePropertyName("currency"); writer.WriteValue(updateFrom.Currency ?? @""); } if (!ExternalParentId.Equals(updateFrom.ExternalParentId)) { writer.WritePropertyName("household_id"); writer.WriteValue(updateFrom.ExternalParentId); } writer.WriteEndObject(); writer.WriteEndObject(); return(sw.ToString()); }
public bool GetObjectNeedsUpate(IncomeSource checkUpdateFrom) { if (!ProductServiceName.Equals(checkUpdateFrom.ProductServiceName)) { return(true); } if (!EstimatedVolumeProduced.Equals(checkUpdateFrom.EstimatedVolumeProduced)) { return(true); } if (!EstimatedVolumeSold.Equals(checkUpdateFrom.EstimatedVolumeSold)) { return(true); } if (!UnitOfMeasure.Equals(checkUpdateFrom.UnitOfMeasure)) { return(true); } if (!EstimatedIncome.Equals(checkUpdateFrom.EstimatedIncome)) { return(true); } if (!Currency.Equals(checkUpdateFrom.Currency)) { return(true); } if (!ExternalParentId.Equals(checkUpdateFrom.ExternalParentId)) { return(true); } return(false); }
public bool ValidateIncomeSource() { // TODO: More "cheatable" char checks or find std regex var validateableName = ProductServiceName.Replace(" ", ""); if (validateableName.Equals(string.Empty)) { ApplicationInstanceData.App.MainPage.DisplayAlert( ApplicationInstanceData.SelectedLocalization.Translations[@"Error"], ApplicationInstanceData.SelectedLocalization.Translations[@"ErrorIncomeSourceNameCanNotBeBlank"], ApplicationInstanceData.SelectedLocalization.Translations[@"OK"]); return(false); } return(true); }