public AttachmentTests() : base(@"http://rest.sandbox-immobilienscout24.de/restapi/api/offer/v1.0") { this.realEstate = new RealEstateItem(new ApartmentRent { id = 4711, idSpecified = true }, Client.Connection); }
public IRealEstate GetRealEstate(string query) { var url = $"fir_lite_rest/api/gkn/fir_lite_object/{query}"; var str = _httpService.RequestGet(url, HttpService.EnumContentType.Json); var obj = JsonConvert.DeserializeObject <JsonObject>(str); IRealEstate realEstate = null; switch (obj.Type) { case "flat": realEstate = JsonConvert.DeserializeObject <JsonFlat>(str); break; case "construction": realEstate = JsonConvert.DeserializeObject <JsonConstruction>(str); break; case "parcel": realEstate = JsonConvert.DeserializeObject <JsonParcel>(str); break; case "building": realEstate = JsonConvert.DeserializeObject <JsonBuilding>(str); break; default: break; } return(realEstate); }
private void CalculateNumberOfResidents(IRealEstate estate, ref double insurance) { if (estate.NumberOfResidents > 3) { insurance += estate.Price / estate.NumberOfResidents; } if (estate.NumberOfResidents == 1) { insurance += estate.Price / 12.5; } }
private void CalculateInsurancePeriod(IRealEstate estate, ref double insurance) { if (estate.InsurancePeriod > 2000) { insurance += estate.Price / 3.2; } else { insurance += estate.Price / 5.31; } }
private void CalculateConstructionDate(IRealEstate estate, ref double insurance) { if (estate.ConstructionYear < 2000) { insurance += (estate.Price / 5.2); } else { insurance += (estate.Price / 3.2); } }
public double GetInsurance(IRealEstate estate) { double insurance = estate.Price; CalculateConstructionDate(estate, ref insurance); CalculateLivingSpace(estate, ref insurance); CalculateInsurancePeriod(estate, ref insurance); CalculateDepreciation(estate, ref insurance); CalculateNumberOfResidents(estate, ref insurance); insurance *= estate.HousingRatio; return(insurance); }
private void CalculateDepreciation(IRealEstate estate, ref double insurance) { if (estate.Depreciation > 10) { insurance += estate.Price / 3.9; } if (estate.Depreciation > 30) { insurance += estate.Price / 3.3; } if (estate.Depreciation > 50) { insurance += estate.Price / 3; } }
private void CalculateLivingSpace(IRealEstate estate, ref double insurance) { if (estate.LivingSpace > 50 && estate.LivingSpace < 100) { insurance += estate.Price / 1.91; } if (estate.LivingSpace > 100) { insurance += estate.Price / 1.81; } else { insurance += estate.Price / 1.71; } }
public static string GetEstateToString(IRealEstate data) { return($"{data.KadastrNumber};" + $"{ReplaceBadChar(data.Address)};" + $"{data.Area};" + $"{data.Cost};" + $"{data.CostDateEntering};" + $"{data.CostDateValuation};" + $"{data.CostDateApproval};" + $"{ReplaceBadChar(data.ObjectDesc)};" + $"{ReplaceBadChar(data.Name)};" + $"{data.ConditionalNumber};" + $"{data.PreviouslyAssignedNumber};" + $"{data.YearUsed};" + $"{data.YearBuilt};"); }
public void Message(IRealEstate realEstate, IFeeCalculator feeCalculator) { var totalCost = feeCalculator.CalculTotal(realEstate.Price, realEstate.Zone); var commissionn = feeCalculator.returnCommissionn(realEstate.Price, realEstate.Zone); Console.WriteLine(); Console.WriteLine("******************************************************************************************************************"); Console.WriteLine(" The price for a/an {0}, before applying the commission is {1} euro.", realEstate.GetType().Name, realEstate.Price); if (realEstate.GetType().Name != "Parcel") { Console.WriteLine(" The address is: {0}, in the {1} zone.", realEstate.Address, realEstate.Zone); } else { Console.WriteLine(" The cadastral number is: {0}, in the {1} zone.", realEstate.Address, realEstate.Zone); } Console.WriteLine(" The price with commissionn is {0} euro and the commissionn is {1} euro.", totalCost, commissionn); Console.WriteLine("******************************************************************************************************************"); }
public static List <string> GetConvertEstateToStrings(IRealEstate data) { var list = new List <string> { $"Кадастровый номер;{data.KadastrNumber}", $"Адрес расположения объекта;{data.Address}", $"Площадь/протяженность;{data.Area}", $"Кадастровая стоимость;{data.Cost}", $"Дата внесения сведений о кадастровой стоимости;{data.CostDateEntering}", $"Дата определения кадастровой стоимости;{data.CostDateValuation}", $"Дата утверждения кадастровой стоимости;{data.CostDateApproval}", $"Тип;{data.ObjectDesc}", $"Наименование объекта/вид объекта недвижимости;{data.Name}", $"Условный номер;{data.ConditionalNumber}", $"Ранее присвоенный номер;{data.PreviouslyAssignedNumber}", $"Год ввода в эксплуатацию;{data.YearUsed}", $"Год завершения строительства;{data.YearBuilt}" }; return(list); }
private static async Task TestAsync(Config config) { var connection = new IS24Connection { ConsumerKey = config.ConsumerKey, ConsumerSecret = config.ConsumerSecret, AccessToken = config.AccessToken, AccessTokenSecret = config.AccessSecret, BaseUrlPrefix = @"https://rest.sandbox-immobilienscout24.de/restapi/api" }; var searchResource = new SearchResource(connection); var query = new RadiusQuery { Latitude = 52.49023, Longitude = 13.35939, Radius = 1, RealEstateType = RealEstateType.APARTMENT_RENT, Parameters = new { Price = new DecimalRange { Max = 1000 }, LivingSpace = new DecimalRange { Min = 100 }, NumberOfRooms = new DecimalRange { Min = 4 }, Equipment = "balcony" }, Channel = new HomepageChannel("me") }; var results = await searchResource.Search(query); var api = new ImportExportClient(connection); RealtorContactDetails contact = null; try { contact = await api.Contacts.GetAsync("Hans Meiser", isExternal : true); } catch (IS24Exception ex) { if (ex.Messages.Message.First().MessageCode != MessageCode.ERROR_RESOURCE_NOT_FOUND) { throw; } } if (contact == null) { contact = new RealtorContactDetails { Lastname = "Meiser", Firstname = "Hans", Address = new Address { Street = "Hauptstraße", HouseNumber = "1", Postcode = "10827", City = "Berlin", InternationalCountryRegion = new CountryRegion { Country = CountryCode.DEU, Region = "Berlin" } }, Email = "*****@*****.**", ExternalId = "Hans Meiser" }; await api.Contacts.CreateAsync(contact); contact.Address.HouseNumber = "1a"; await api.Contacts.UpdateAsync(contact); } IRealEstate realEstate = null; try { realEstate = await api.RealEstates.GetAsync("Hauptstraße 1", isExternal : true); } catch (IS24Exception ex) { if (ex.Messages.Message.First().MessageCode != MessageCode.ERROR_RESOURCE_NOT_FOUND) { throw; } } if (realEstate == null) { var re = new ApartmentRent { Contact = new RealEstateContact { Id = contact.Id }, ExternalId = "Hauptstraße 1", Title = "IS24RestApi Test", Address = new Wgs84Address { Street = "Hauptstraße", HouseNumber = "1", City = "Berlin", Postcode = "10827" }, BaseRent = 500.0, LivingSpace = 100.0, NumberOfRooms = 4.0, ShowAddress = true, Courtage = new CourtageInfo { HasCourtage = YesNoNotApplicableType.NO } }; await api.RealEstates.CreateAsync(re); re.BaseRent += 100.0; await api.RealEstates.UpdateAsync(re); realEstate = new RealEstateItem(re, connection); } else { var re = (ApartmentRent)realEstate.RealEstate; re.BaseRent += 100.0; await api.RealEstates.UpdateAsync(re); re.BaseRent -= 100.0; await api.RealEstates.UpdateAsync(re); } var projects = await api.RealEstateProjects.GetAllAsync(); if (projects.RealEstateProject.Any()) { var project = projects.RealEstateProject.First(); var entries = await api.RealEstateProjects.GetAllAsync(project.Id.Value); if (!entries.RealEstateProjectEntry.Any(e => e.RealEstateId.Value == realEstate.RealEstate.Id.Value)) { await api.RealEstateProjects.AddAsync(project.Id.Value, realEstate.RealEstate); } } var placement = await realEstate.PremiumPlacements.GetAsync(); var a1 = new KeyValuePair <Attachment, string>(new Picture { Title = "Zimmer 1", Floorplan = false, TitlePicture = true }, @"..\..\..\test.jpg"); var a2 = new KeyValuePair <Attachment, string>(new Picture { Title = "Zimmer 2" }, @"..\..\..\test.jpg"); var a3 = new KeyValuePair <Attachment, string>(new Picture { Title = "Zimmer 3" }, @"..\..\..\test.jpg"); var pdf = new KeyValuePair <Attachment, string>(new PDFDocument { Title = "Test" }, @"..\..\..\test.pdf"); var video = new KeyValuePair <Attachment, string>(new StreamingVideo { Title = "Video" }, @"..\..\..\test.avi"); var link = new KeyValuePair <Attachment, string>(new Link { Title = "Test", Url = "http://www.example.com/" }, null); var atts = new[] { video, a1, pdf, a2, link, a3 }; await realEstate.Attachments.UpdateAsync(atts); var res = new List <RealEstate>(); await api.RealEstates.GetAsync().ForEachAsync(x => res.Add(x.RealEstate)); }
private static async Task TestAsync() { var config = RestSharp.SimpleJson.DeserializeObject <Config>(File.ReadAllText("config.json")); var connection = new IS24Connection { ConsumerKey = config.ConsumerKey, ConsumerSecret = config.ConsumerSecret, AccessToken = config.AccessToken, AccessTokenSecret = config.AccessSecret, BaseUrlPrefix = @"http://rest.sandbox-immobilienscout24.de/restapi/api/offer/v1.0" }; var api = new ImportExportClient(connection); RealtorContactDetails contact = null; try { contact = await api.Contacts.GetAsync("Hans Meiser", isExternal : true); } catch (IS24Exception ex) { if (ex.Messages.message.First().messageCode != MessageCode.ERROR_RESOURCE_NOT_FOUND) { throw; } } if (contact == null) { contact = new RealtorContactDetails { lastname = "Meiser", firstname = "Hans", email = "*****@*****.**", address = new Address { street = "Hauptstraße", houseNumber = "1", postcode = "10827", city = "Berlin", internationalCountryRegion = new CountryRegion { country = CountryCode.DEU, region = "Berlin" } }, externalId = "Hans Meiser" }; await api.Contacts.CreateAsync(contact); contact.address.houseNumber = "1a"; await api.Contacts.UpdateAsync(contact); } IRealEstate realEstate = null; try { realEstate = await api.RealEstates.GetAsync("Hauptstraße 1", isExternal : true); } catch (IS24Exception ex) { if (ex.Messages.message.First().messageCode != MessageCode.ERROR_RESOURCE_NOT_FOUND) { throw; } } if (realEstate == null) { var re = new ApartmentRent { contact = new RealEstateContact { id = contact.id, idSpecified = true }, externalId = "Hauptstraße 1", title = "IS24RestApi Test", address = new Wgs84Address { street = "Hauptstraße", houseNumber = "1", city = "Berlin", postcode = "10827" }, baseRent = 500.0, livingSpace = 100.0, numberOfRooms = 4.0, showAddress = true, courtage = new CourtageInfo { hasCourtage = YesNoNotApplicableType.NO } }; await api.RealEstates.CreateAsync(re); re.baseRent += 100.0; await api.RealEstates.UpdateAsync(re); realEstate = new RealEstateItem(re, connection); } var atts = await realEstate.Attachments.GetAsync(); if (atts == null || !atts.Any()) { var att = new Picture { floorplan = false, titlePicture = true, title = "Zimmer", }; await realEstate.Attachments.CreateAsync(att, @"..\..\test.jpg"); att.title = "Zimmer 1"; await realEstate.Attachments.UpdateAsync(att); } await api.Publish.PublishAsync(realEstate.RealEstate); await api.Publish.UnpublishAsync(realEstate.RealEstate); var res = new List <RealEstate>(); await api.RealEstates.GetAsync().ForEachAsync(x => res.Add(x.RealEstate)); }