public void Copy(RuralListing newRuralListing)
        {
            if (newRuralListing == null)
            {
                throw new ArgumentNullException("newRuralListing");
            }

            base.Copy(newRuralListing);

            if (newRuralListing.IsCategoryTypeModified)
            {
                CategoryType = newRuralListing.CategoryType;
            }

            if (newRuralListing.IsPricingModified)
            {
                if (newRuralListing.Pricing == null)
                {
                    Pricing = null;
                }
                else
                {
                    if (Pricing == null)
                    {
                        Pricing = new SalePricing();
                    }

                    if (newRuralListing.Pricing.IsModified)
                    {
                        Pricing.Copy(newRuralListing.Pricing);
                    }

                    IsPricingModified = true;
                }
            }

            if (newRuralListing.IsAuctionOnModified)
            {
                AuctionOn = newRuralListing.AuctionOn;
            }

            if (newRuralListing.IsRuralFeaturesModified)
            {
                if (newRuralListing.RuralFeatures == null)
                {
                    RuralFeatures = null;
                }
                else
                {
                    if (RuralFeatures == null)
                    {
                        RuralFeatures = new RuralFeatures();
                    }

                    if (newRuralListing.RuralFeatures.IsModified)
                    {
                        RuralFeatures.Copy(newRuralListing.RuralFeatures);
                    }

                    IsRuralFeaturesModified = true;
                }
            }

            if (newRuralListing.IsCouncilRatesModified)
            {
                CouncilRates = newRuralListing.CouncilRates;
            }

            if (newRuralListing.IsBuildingDetailsModified)
            {
                if (newRuralListing.BuildingDetails == null)
                {
                    BuildingDetails = null;
                }
                else
                {
                    if (BuildingDetails == null)
                    {
                        BuildingDetails = new BuildingDetails();
                    }

                    if (newRuralListing.BuildingDetails.IsModified)
                    {
                        BuildingDetails.Copy(newRuralListing.BuildingDetails);
                    }

                    IsBuildingDetailsModified = true;
                }
            }
        }
Exemple #2
0
        public void Copy(RuralListing newRuralListing)
        {
            if (newRuralListing == null)
            {
                throw new ArgumentNullException("newRuralListing");
            }

            base.Copy(newRuralListing);

            if (newRuralListing.IsCategoryTypeModified)
            {
                CategoryType = newRuralListing.CategoryType;
            }

            if (newRuralListing.IsPricingModified)
            {
                if (newRuralListing.Pricing == null)
                {
                    Pricing = null;
                }
                else
                {
                    if (Pricing == null)
                    {
                        Pricing = new SalePricing();
                    }

                    if (newRuralListing.Pricing.IsModified)
                    {
                        Pricing.Copy(newRuralListing.Pricing);
                    }

                    IsPricingModified = true;
                }
            }

            if (newRuralListing.IsAuctionOnModified)
            {
                AuctionOn = newRuralListing.AuctionOn;
            }

            if (newRuralListing.IsRuralFeaturesModified)
            {
                if (newRuralListing.RuralFeatures == null)
                {
                    RuralFeatures = null;
                }
                else
                {
                    if (RuralFeatures == null)
                    {
                        RuralFeatures = new RuralFeatures();
                    }

                    if (newRuralListing.RuralFeatures.IsModified)
                    {
                        RuralFeatures.Copy(newRuralListing.RuralFeatures);
                    }

                    IsRuralFeaturesModified = true;
                }
            }

            if (newRuralListing.IsCouncilRatesModified)
            {
                CouncilRates = newRuralListing.CouncilRates;
            }

            if (newRuralListing.IsBuildingDetailsModified)
            {
                if (newRuralListing.BuildingDetails == null)
                {
                    BuildingDetails = null;
                }
                else
                {
                    if (BuildingDetails == null)
                    {
                        BuildingDetails = new BuildingDetails();
                    }

                    if (newRuralListing.BuildingDetails.IsModified)
                    {
                        BuildingDetails.Copy(newRuralListing.BuildingDetails);
                    }

                    IsBuildingDetailsModified = true;
                }
            }
        }
 public static RuralListing RuralListing(bool isClearAllIsModified = true)
 {
     var listing = new RuralListing
     {
         CategoryType = RuralListingCategoryType.Horticulture,
         AuctionOn = new DateTime(2015, 5, 23),
         CouncilRates = "some council rates",
         RuralFeatures = new RuralFeatures
         {
             AnnualRainfall = "some rain",
             CarryingCapacity = "some carrying capacity",
             Fencing = "some fencing",
             Improvements = "lots of improvements",
             Irrigation = "some irrigation",
             Services = "a number of services",
             SoilTypes = "dirty soil"
         },
         Pricing = new SalePricing
         {
             IsUnderOffer = true,
             SalePrice = 12345.66m,
             SalePriceText = "house for sale",
             SoldOn = new DateTime(2015, 6, 1),
             SoldPrice = 45432.99m,
             SoldPriceText = "just sold woot!"
         },
         BuildingDetails = new BuildingDetails
         {
             Area = new UnitOfMeasure
             {
                 Type = "Some type",
                 Value = 1.2345m
             },
             EnergyRating = 111.222m,
         }
     };
  
     if (isClearAllIsModified)
     {
         listing.ClearAllIsModified();
     }
     return listing;
 }
            private static void AssertRuralSoldListing(RuralListing listing, bool isSoldPriceVisibile = true)
            {
                listing.AgencyId.ShouldBe("XNWXNW");
                listing.Id.ShouldBe("Rural-Sold-ABCD1234");
                listing.StatusType.ShouldBe(StatusType.Sold);

                decimal? soldPrice = 85000m;
                listing.Pricing.SoldPrice.ShouldBe(soldPrice);
                listing.Pricing.SoldPriceText.ShouldBe(isSoldPriceVisibile
                    ? soldPrice.Value.ToString("C0")
                    : null);
                listing.Pricing.SoldOn.ShouldBe(new DateTime(2009, 01, 10, 12, 30, 00));
            }
            private static void AssertRuralCurrentListing(RuralListing listing,
                IList<string> tags = null,
                bool isModified = true,
                int bedroomsCount = 0)
            {
                listing.AgencyId.ShouldBe("XNWXNW");
                listing.Id.ShouldBe("Rural-Current-ABCD1234");
                listing.StatusType.ShouldBe(StatusType.Current);
                listing.CategoryType.ShouldBe(CategoryType.Cropping);
                listing.AuctionOn.ShouldBe(new DateTime(2009, 01, 24, 14, 30, 00));
                listing.CouncilRates.ShouldBe("$2,200 per annum");

                listing.Agents.Count.ShouldBe(1);
                listing.Agents[0].Name.ShouldBe("Mr. John Doe");
                listing.Agents[0].Communications.Count.ShouldBe(2);

                listing.Address.StreetNumber.ShouldBe("39");
                listing.Address.Street.ShouldBe("Main Road");
                listing.Address.Suburb.ShouldBe("RICHMOND");
                listing.Address.IsStreetDisplayed.ShouldBe(true);

                listing.Title.ShouldBe("SHOW STOPPER!!!");
                listing.Description.ShouldStartWith(
                    "Don't pass up an opportunity like this! First to inspect will buy! Close to local amen");

                listing.Pricing.IsUnderOffer.ShouldBe(false);
                listing.Pricing.SalePrice.ShouldBe(400000);
                listing.Pricing.SalePriceText.ShouldBe(null);

                listing.LandDetails.Area.Value.ShouldBe(50);
                listing.LandDetails.Area.Type.ShouldBe("acre");
                listing.LandDetails.Frontage.Value.ShouldBe(500);
                listing.LandDetails.Frontage.Type.ShouldBe("meter");
                listing.LandDetails.Depths[0].Value.ShouldBe(400);
                listing.LandDetails.Depths[0].Type.ShouldBe("meter");
                listing.LandDetails.Depths[0].Side.ShouldBe("rear");

                listing.Inspections.Count.ShouldBe(2);

                listing.Images.Count.ShouldBe(2);
                listing.FloorPlans.Count.ShouldBe(2);

                listing.RuralFeatures.AnnualRainfall.ShouldBe("250 mm per annum");
                listing.RuralFeatures.CarryingCapacity.ShouldBe("400 Deer or 100 head of breeding Cattle");
                listing.RuralFeatures.Fencing.ShouldBe("Boundary and internal fencing all in good condition");
                listing.RuralFeatures.Improvements.ShouldBe("Shearing shed, barn and machinery shed.");
                listing.RuralFeatures.Irrigation.ShouldBe("Electric pump from dam and bore.");
                listing.RuralFeatures.Services.ShouldBe("Power, telephone, airstrip, school bus, mail.");
                listing.RuralFeatures.SoilTypes.ShouldBe("red basalt");

                AssertFeatures(listing.Features, 
                    tags, 
                    isModified, 
                    bedroomsCount,
                    2,
                    2);
            }
        private static Listing CreateListing(CategoryType categoryType)
        {
            Listing listing;

            switch (categoryType)
            {
                case CategoryType.Sale:
                    listing = new ResidentialListing();
                    break;
                case CategoryType.Rent:
                    listing = new RentalListing();
                    break;
                case CategoryType.Land:
                    listing = new LandListing();
                    break;
                case CategoryType.Rural:
                    listing = new RuralListing();
                    break;
                default:
                    // Not sure if we should do some logging here?
                    listing = null;
                    break;
            }

            return listing;
        }
        private static void ExtractRuralNewConstruction(XElement document, RuralListing listing)
        {
            document.ShouldNotBe(null);
            listing.ShouldNotBe(null);

            if (!document.BoolValueOrDefault("newConstruction"))
            {
                return;
            }

            if (listing.Features == null)
            {
                listing.Features = new Features();
            }

            if (listing.Features.Tags == null)
            {
                listing.Features.Tags = new HashSet<string>();
            }

            listing.Features.Tags.Add("isANewConstruction");
        }
        private static void ExtractRuralData(RuralListing ruralListing, XElement document, CultureInfo cultureInfo)
        {
            document.ShouldNotBe(null);

            ruralListing.CategoryType = ExtractRuralCategoryType(document);
            ruralListing.Pricing = ExtractSalePricing(document, cultureInfo);
            ruralListing.AuctionOn = ExtractAuction(document);
            ruralListing.RuralFeatures = ExtractRuralFeatures(document);
            ruralListing.CouncilRates = ExtractRuralCouncilRates(document);
            ruralListing.BuildingDetails = ExtractBuildingDetails(document);
            ExtractRuralNewConstruction(document, ruralListing);
        }