public override Listing ToOreListing() { var listing = new RentalListing(); CopyOverListingData(listing); listing.CreatedOn = LeasedOn; listing.UpdatedOn = LeasedOn; listing.StatusType = StatusType.Leased; listing.SourceStatus = StatusType.Leased.ToString(); listing.PropertyType = PropertyTypeHelpers.ToPropertyType(PropertyType); listing.Pricing = new RentalPricing { RentalPrice = RentPrice, RentedOn = LeasedOn }; var rentalPriceText = RentPrice > 0 ? $"${RentPrice:N0}" : "price undisclosed"; listing.Title = $"Rented: {rentalPriceText}."; return(listing); }
public static RentalListing RentalListing(bool isClearAllIsModified = true) { var listing = new RentalListing { AvailableOn = new DateTime(2015, 5, 23), BuildingDetails = new BuildingDetails { Area = new UnitOfMeasure { Type = "Some type", Value = 1.2345m }, EnergyRating = 111.222m, }, PropertyType = PropertyType.Townhouse, Pricing = new RentalPricing { RentalPrice = 567.88m, RentalPriceText = "house for rent", Bond = 1000m, PaymentFrequencyType = PaymentFrequencyType.Monthly } }; if (isClearAllIsModified) { listing.ClearAllIsModified(); } return(listing); }
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); }
public void AddRentalListing(RentalListing listing) { if (!_context.RentalListings.Any(l => l.Id == listing.Id)) { // Only add if doesn't already exist. _context.RentalListings.Add(listing); } }
protected static RentalListing FakeRentallListing(StatusType statusType) { var listing = new RentalListing(); SetupListing(listing, statusType); return(listing); }
public static ValidationResult Validate(RentalListing rentalListing, string ruleSet = RentalListingValidator.NormalRuleSet) { var validator = new RentalListingValidator(); return(string.IsNullOrWhiteSpace(ruleSet) ? validator.Validate(rentalListing) : validator.Validate(rentalListing, ruleSet: ruleSet)); }
private static void SetRentalPricing(RentalListing listing) { listing.Pricing = new RentalPricing { PaymentFrequencyType = PaymentFrequencyType.Weekly, RentalPrice = 350, RentalPriceText = "$350", Bond = 999 }; }
private static void AssertRentalListing(ParsedResult result, RentalListing expectedListing) { result.ShouldNotBeNull(); result.Listings.Count.ShouldBe(1); result.Errors.Count.ShouldBe(0); result.UnhandledData.Count.ShouldBe(0); RentalListingAssertHelpers.AssertRuralListing(result.Listings.First().Listing as RentalListing, expectedListing); }
public static void AssertRuralListing(RentalListing source, RentalListing destination) { ListingAssertHelpers.AssertCommonData(source, destination); BuildingDetailsAssertHelpers.AssertBuildingDetails(source.BuildingDetails, destination.BuildingDetails); AssertRentalPricing(source.Pricing, destination.Pricing); source.AvailableOn.ShouldBe(destination.AvailableOn); source.PropertyType.ShouldBe(destination.PropertyType); }
private static void AssertRentalCurrentListing(RentalListing listing) { listing.AgencyId.ShouldBe("XNWXNW"); listing.Id.ShouldBe("Rental-Current-ABCD1234"); listing.StatusType.ShouldBe(StatusType.Current); listing.PropertyType.ShouldBe(PropertyType.House); listing.Address.IsStreetDisplayed.ShouldBe(true); listing.Address.StreetNumber.ShouldBe("39"); listing.Address.Street.ShouldBe("Main Road"); listing.Address.Suburb.ShouldBe("RICHMOND"); listing.Address.State.ShouldBe("vic"); listing.Address.CountryIsoCode.ShouldBe("AU"); listing.Address.Postcode.ShouldBe("3121"); listing.AvailableOn.ShouldBe(new DateTime(2009, 01, 26, 12, 30, 00)); listing.Pricing.RentalPrice.ShouldBe(350); listing.Pricing.RentalPriceText.ShouldBe("350"); listing.Pricing.PaymentFrequencyType.ShouldBe(PaymentFrequencyType.Weekly); listing.Pricing.Bond.ShouldBe(999); listing.Inspections.Count.ShouldBe(2); listing.Agents.Count.ShouldBe(1); var listingAgent = listing.Agents[0]; listingAgent.Name.ShouldBe("Mr. John Doe"); listingAgent.Order.ShouldBe(1); listingAgent.Communications[0].CommunicationType.ShouldBe(CommunicationType.Email); listingAgent.Communications[0].Details.ShouldBe("*****@*****.**"); listingAgent.Communications[1].CommunicationType.ShouldBe(CommunicationType.Landline); listingAgent.Communications[1].Details.ShouldBe("05 1234 5678"); listing.Features.Bedrooms.ShouldBe(4); listing.Features.Bathrooms.ShouldBe(2); listing.Features.CarSpaces.ShouldBe(2); listing.Images.Count.ShouldBe(2); listing.Images[0].Order.ShouldBe(1); listing.Images[0].Url.ShouldBe("http://www.realestate.com.au/tmp/imageM.jpg"); listing.LandDetails.Area.Value.ShouldBe(60M); listing.LandDetails.Area.Type.ShouldBe("square"); listing.LandDetails.Frontage.Value.ShouldBe(15M); listing.LandDetails.Frontage.Type.ShouldBe("meter"); listing.LandDetails.Depth.Value.ShouldBe(40M); listing.LandDetails.Depth.Type.ShouldBe("meter"); listing.LandDetails.Depth.Side.ShouldBe("rear"); listing.FloorPlans.Count.ShouldBe(2); }
public static ServiceResponseResult AddRentalListing(RentListingModel model, HttpFileCollectionBase files, Login user) { using (var db = new KeysEntities()) { var foundProp = db.OwnerProperty.FirstOrDefault(x => x.PropertyId == model.PropertyId && x.OwnerId == user.Id); if (foundProp == null) { return(new ServiceResponseResult { IsSuccess = false, ErrorMessage = "Can not find property." }); } var newRentalListing = new RentalListing { PropertyId = model.PropertyId, Description = model.Description, Title = model.Title = model.Title, MovingCost = model.MovingCost, TargetRent = model.TargetRent, AvailableDate = model.AvailableDate, Furnishing = model.Furnishing, IdealTenant = model.IdealTenant, OccupantCount = model.OccupantCount, PetsAllowed = model.PetsAllowed, CreatedBy = user.Email, CreatedOn = DateTime.UtcNow, UpdatedBy = user.Email, IsActive = true, RentalStatusId = 1 }; var fileList = MediaService.SaveMediaFiles(files, 5, null).NewObject as List <MediaModel>; if (fileList != null) { fileList.ForEach(x => newRentalListing.RentalListingMedia.Add(new RentalListingMedia { NewFileName = x.NewFileName, OldFileName = x.OldFileName })); } db.RentalListing.Add(newRentalListing); try { db.SaveChanges(); return(new ServiceResponseResult { IsSuccess = true }); } catch (Exception ex) { return(new ServiceResponseResult { IsSuccess = true, ErrorMessage = _error }); } } }
private static void ExtractRentalData(RentalListing rentalListing, XElement xElement, CultureInfo cultureInfo) { rentalListing.ShouldNotBe(null); xElement.ShouldNotBe(null); var dateAvailble = xElement.ValueOrDefault("dateAvailable"); if (!string.IsNullOrWhiteSpace(dateAvailble)) { rentalListing.AvailableOn = ToDateTime(dateAvailble); } rentalListing.PropertyType = ExtractResidentialAndRentalPropertyType(xElement); rentalListing.Pricing = ExtractRentalPricing(xElement, cultureInfo); rentalListing.Features = ExtractFeatures(xElement); }
public static RentalListing CreateAFakeRentalListing(string id = "Rental-Current-ABCD1234", PropertyType propertyType = PropertyType.House) { var listing = new RentalListing() { Id = id }; FakeCommonListingHelpers.SetCommonListingData(listing); listing.Features.Tags.Remove("houseAndLandPackage"); FakeCommonListingHelpers.SetBuildingDetails(listing); SetRentalPricing(listing); listing.AvailableOn = new DateTime(2009, 1, 26, 12, 30, 00, DateTimeKind.Utc); listing.PropertyType = propertyType; return(listing); }
public IActionResult Post([FromBody] RentalListing value) { _repository.AddRentalListing(value); _repository.SaveChanges(); return(StatusCode(201, value)); }