using System.Text; using Castle.ActiveRecord; namespace ECOEarth.Web.Domain { [ActiveRecord] public class Address : ActiveRecordBase
{ private string streetAddress; private string secondLine; private string townCity; private string county; private string country; private string postcode; private int addressId; [PrimaryKey] public virtual int AddressId { get { return addressId; } set { addressId = value; } } [Property] public virtual string StreetAddress { get { return streetAddress; } set { streetAddress = value; } } [Property] public virtual string SecondLine { get { return secondLine; } set { secondLine = value; } } [Property] public virtual string TownCity { get { return townCity; } set { townCity = value; } } [Property] public virtual string County { get { return county; } set { county = value; } } [Property] public virtual string Country { get { return country; } set { country = value; } } [Property] public virtual string Postcode { get { return postcode; } set { postcode = value; } } public string ToFormattedAddressString() { StringBuilder addressBuilder = new StringBuilder(); addressBuilder.AppendLine(this.StreetAddress); if(this.SecondLine.Trim().Length == 0) { addressBuilder.AppendLine(this.secondLine); } addressBuilder.AppendLine(this.townCity); addressBuilder.AppendLine(this.county); addressBuilder.AppendLine(this.country); addressBuilder.AppendLine(this.postcode); return addressBuilder.ToString(); } } }