using System.Windows.Media; namespace BS.Shared.DataContracts.Compact { public partial class CompactPersonDC : IFilterableDC { public string AddressString { get { string address = this.Street; if (address != null && address.Length > 0) { address += ", "; } address = address + this.PostalCode + " " + this.Town; if (!string.IsNullOrEmpty(Organisation)) address = Organisation + ", " + address; return address; } } public SolidColorBrush FilterableBrush { get { return new SolidColorBrush(Colors.Transparent); } } public string AddressSummaryInfo { get { string address = this.Street; if (address != null && address.Length > 0) { address += "\n"; } if (address == null) { address = string.Empty; } address += this.PostalCode + " " + this.Town; return address; } set { } } public string ContactSummaryInfo { get { string info = string.Empty; if (!string.IsNullOrEmpty(this.Communication1)) info = "Tel.: " + this.Communication1; if (!string.IsNullOrEmpty(this.Communication2)) { if (info.Length > 0) info += "\n"; info += "Mobil: " + this.Communication2; } if (!string.IsNullOrEmpty(this.Communication3)) { if (info.Length > 0) info += "\n"; info += "E-Mail: " + this.Communication3; } if (!string.IsNullOrEmpty(this.Communication4)) { if (info.Length > 0) info += "\n"; info += "Fax: " + this.Communication4; } return info; } set { } } public string CommunicationString { get { string info = string.Empty; if (!string.IsNullOrEmpty(this.Communication1)) info = this.Communication1; if (!string.IsNullOrEmpty(this.Communication2)) { if (info.Length > 0) info += " "; info += this.Communication2; } if (!string.IsNullOrEmpty(this.Communication3)) { if (info.Length > 0) info += " "; info += this.Communication3; } if (!string.IsNullOrEmpty(this.Communication4)) { if (info.Length > 0) info += " "; info += this.Communication4; } return info; } set { } } public string Birthday { get { if (this.DateOfBirth != null) { return this.DateOfBirth.Value.ToShortDateString(); } return null; } } public string DetailDescription { // get { return ToString() + (DateOfBirth.HasValue ? " (" + DateOfBirth.Value.ToShortDateString() + ")" : ""); } get { return this.ToString(); } } public string FilterRelevants { get { return this.Title + " " + this.FirstName + " " + this.LastName + " " + this.Function + " " + this.AddressString + " " + this.CommunicationString + " " + this.Organisation; } } public string FullName { get { return this.FirstName + " " + this.LastName; } } public string IconPath { get { return @"..\..\Ressources\Icons\AnonymousUserDisabled.png"; } } public bool IsArchived { get { return this.ActivationType == ActivationTypeId.Archived; } } public bool IsDeleted { get { return this.ActivationType == ActivationTypeId.Deleted; } } public string SimpleDescription { get { return this.ToString(); } } public bool SupportsActivationType { get { return true; } } public long Version { get { return this.PersonVersion; } set { this.PersonVersion = value; } } public override bool Equals(object obj) { if (obj is CompactPersonDC) { CompactPersonDC compactPerson = obj as CompactPersonDC; return this.PersonOid == compactPerson.PersonOid && this.Organisation == compactPerson.Organisation; } return false; } public override int GetHashCode() { if (!string.IsNullOrEmpty(Organisation)) return this.GetType().Name.GetHashCode() ^ this.PersonOid.GetHashCode() ^ this.Organisation.GetHashCode(); else return this.GetType().Name.GetHashCode() ^ this.PersonOid.GetHashCode(); } public override string ToString() { string name = this.FirstName; if (!string.IsNullOrEmpty(name)) { name = this.LastName + ", " + name; } else { name = this.LastName; } if (!string.IsNullOrEmpty(Title)) { name = Title + " " + name; } return name; } public string TitleFirstNameLastNameToString() { var tfn = string.Empty; if (!string.IsNullOrEmpty(Title)) tfn += string.Format("{0} ", Title); tfn += string.Format("{0} {1}", FirstName, LastName); return tfn; } } }