/// <summary>Creates a new <see cref="SiteInfo"/> instance from the given BPL site entity and given (optional) operator.</summary> public SiteInfo(Site site, Operator opco) { if (site == null) return; SiteId = Class.CreateId(site.Id.LocalId); Operator = opco; Type = site.PoiType; Position = site.Position; if (!site.LocalizedName.IsEmpty) { Name = site.LocalizedName; } else if (site.Name.NotEmpty()) { Name = new MultiString(site.Name); } if (!site.LocalizedAddress.IsEmpty) { Address = (MultiAddress)site.LocalizedAddress; } else if (site.Address != null) { Address = new MultiAddress(site.Address); } var biz = site.BusinessInfo; if (biz != null) { Description = biz.Description; WorkingHours = biz.WorkingHours; if (biz.RatingCount > 0) { RatingCount = biz.RatingCount; RatingScore = ((Percent)biz.RatingScore).Normalize(); } else { RatingScore = Percent.Undefined; } foreach (var p in biz.PhoneNumbers) { Contacts.Add(new Contact { Type = ContactTypes.Phone, Value = p.ToString() }); } if (biz.Email.NotEmpty()) { Contacts.Add(new Contact { Type = ContactTypes.Email, Value = biz.Email }); } if (biz.Website.NotEmpty()) { Contacts.Add(new Contact { Type = ContactTypes.Website, Value = biz.Website }); } CustomProperties = biz.CustomProperties; } }
private static Contact _getAddress(A.Address address, Operator opco, ContactType type) { if (address == null || opco == null) return null; var addr = new AddressStruct { CityName = address.city, CountryCode = opco.CountryCode, HouseNumber = address.streetNumber, PostalCode = address.postcode, StreetName = address.streetName, ZipCode = address.postcode }; return new Contact { Type = type, Value = _formatPrimaryAddress(addr) }; }
private Contact _getContactInfo(A.ContactMethodInfo c, Operator opco) { ContactType type = null; if (c.contactMethodType == "PH") type = ContactTypes.Phone; else if (c.contactMethodType == "EM") type = ContactTypes.Email; else if (c.contactMethodType == "MO" || c.contactMethodType == "M") type = ContactTypes.MobilePhone; else { Log.Warn("Unknown Contact type {0}", c.contactMethodType); type = ContactTypes.OtherAddress; } return new Contact { Type = type, Value = c.contactMethodValue }; }
private static bool _applyImplicitValue(BplContextNode input, BplProperty property, Operator implicitValue) { if (property.UnderlyingType.IsA<BplIdentity>()) { return _applyImplicitValue(input, property, implicitValue != null ? implicitValue.Id : BplIdentity.Empty); } var inputValue = property.GetValue(input) as Operator; if (inputValue == null) { property.SetValue(input, implicitValue); return true; } else { return inputValue == implicitValue; } }