public void Copy(RentalPricing newRentalPricing) { if (newRentalPricing == null) { throw new ArgumentNullException("newRentalPricing"); } if (newRentalPricing.IsRentalPriceModified) { RentalPrice = newRentalPricing.RentalPrice; } if (newRentalPricing.IsPaymentFrequencyTypeModified) { PaymentFrequencyType = newRentalPricing.PaymentFrequencyType; } if (newRentalPricing.IsRentalPriceTextModified) { RentalPriceText = newRentalPricing.RentalPriceText; } if (newRentalPricing.IsBondModified) { Bond = newRentalPricing.Bond; } }
public void Copy(RentalListing newRentalListing) { if (newRentalListing == null) { throw new ArgumentNullException("newRentalListing"); } base.Copy(newRentalListing); if (newRentalListing.IsPropertyTypeModified) { PropertyType = newRentalListing.PropertyType; } if (newRentalListing.IsAvailableOnModified) { AvailableOn = newRentalListing.AvailableOn; } if (newRentalListing.IsPricingModified) { if (newRentalListing.Pricing == null) { Pricing = null; } else { if (Pricing == null) { Pricing = new RentalPricing(); } if (newRentalListing.Pricing.IsModified) { Pricing.Copy(newRentalListing.Pricing); } IsPricingModified = true; } } if (newRentalListing.IsBuildingDetailsModified) { if (newRentalListing.BuildingDetails == null) { BuildingDetails = null; } else { if (BuildingDetails == null) { BuildingDetails = new BuildingDetails(); } if (newRentalListing.BuildingDetails.IsModified) { BuildingDetails.Copy(newRentalListing.BuildingDetails); } IsBuildingDetailsModified = true; } } }
// REF: http://reaxml.realestate.com.au/docs/reaxml1-xml-format.html#rent private static RentalPricing ExtractRentalPricing(XElement xElement, CultureInfo cultureInfo) { xElement.ShouldNotBe(null); // Quote: There can be multiple rent elements if you wish to specify a price for both monthly and weekly. // However, at least one of the rent elements must be for a weekly period. // Result: FML :( var rentElements = xElement.Elements("rent").ToArray(); if (!rentElements.Any()) { return null; } // We will only use the WEEKLY one. var rentalPricing = new RentalPricing(); foreach (var rentElement in rentElements) { // Have to have a period. var frequency = rentElement.AttributeValueOrDefault("period"); if (string.IsNullOrWhiteSpace(frequency)) { continue; } if (frequency.Equals("week", StringComparison.InvariantCultureIgnoreCase) || frequency.Equals("weekly", StringComparison.InvariantCultureIgnoreCase)) { rentalPricing.PaymentFrequencyType = PaymentFrequencyType.Weekly; } else if (frequency.Equals("month", StringComparison.InvariantCultureIgnoreCase) || frequency.Equals("monthly", StringComparison.InvariantCultureIgnoreCase)) { rentalPricing.PaymentFrequencyType = PaymentFrequencyType.Monthly; } rentalPricing.RentalPrice = rentElement.MoneyValueOrDefault(cultureInfo); var displayAttributeValue = rentElement.AttributeValueOrDefault("display"); var isDisplay = string.IsNullOrWhiteSpace(displayAttributeValue) || displayAttributeValue.ParseOneYesZeroNoToBool(); rentalPricing.RentalPriceText = isDisplay ? rentalPricing.RentalPrice.ToString("C0") : null; // NOTE: We only parse the first one. You have more than one? Pffftttt!!! Die! break; } // NOTE: Even though we have set the rental price text to be the last // rental period's value ... this can now be overwritten by // whatever value they might have in here ... if they have a value. var priceView = xElement.ValueOrDefault("priceView"); if (!string.IsNullOrWhiteSpace(priceView)) { rentalPricing.RentalPriceText = priceView; } rentalPricing.Bond = xElement.MoneyValueOrDefault(cultureInfo, "bond"); return rentalPricing; }