From 7d4d05c61d4fb5d0a049b979e7aa4519a1c2ae4a Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Mon, 5 Nov 2012 15:59:40 +0000 Subject: [PATCH] Added serializability to Geography, methods to Automation/GetGeographyData --- Basic/Types/BasicGeography.cs | 12 ++++++------ Site5/Automation/GetGeographyData.asmx | 11 +++++++++++ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/Basic/Types/BasicGeography.cs b/Basic/Types/BasicGeography.cs index a338af43..fec7f09e 100644 --- a/Basic/Types/BasicGeography.cs +++ b/Basic/Types/BasicGeography.cs @@ -30,24 +30,24 @@ namespace Activizr.Basic.Types } /// - /// The database node id. + /// The database id of this geography. /// - public readonly int GeographyId; + public int GeographyId { get; private set; } /// - /// The database node id of the parent node. + /// The database id of the parent geography, for linking in a tree structure. /// - public readonly int ParentGeographyId; + public int ParentGeographyId { get; protected set; } /// /// The friendly name of the node (city, county, region, etc). /// - public readonly string Name; + public string Name { get; protected set; } /// /// The generation of this node. Used in tree-style listings. /// - public readonly int Generation; + public int Generation { get; protected set; } #region IHasIdentity Members diff --git a/Site5/Automation/GetGeographyData.asmx b/Site5/Automation/GetGeographyData.asmx index 497e32a4..84e35d70 100644 --- a/Site5/Automation/GetGeographyData.asmx +++ b/Site5/Automation/GetGeographyData.asmx @@ -35,4 +35,15 @@ public class GetGeographyData : System.Web.Services.WebService { return PostalCodes.ForCountry(countryCode); } + public Geographies GetGeographiesFromRoot (int rootId) + { + return Geography.FromIdentity(rootId).GetTree(); + } + + public Geographies GetGeographiesForCountry (string countryCode) + { + Country country = Country.FromCode(countryCode); + return GetGeographiesFromRoot(country.GeographyId); + } + } \ No newline at end of file