using System.Windows.Media;
using BS.Shared.Extensions;

namespace BS.Shared.DataContracts.Compact
{
    public partial class CompactOrganisationDC : IFilterableDC
    {
       

        public bool IsArchived
        {
            get
            {
                return this.ActivationType == ActivationTypeId.Archived;
            }
        }

		public bool IsDeleted
		{
			get
			{
				return this.ActivationType == ActivationTypeId.Deleted;
			}
		}

        public string AddressString
        {
            get
            {
                string address = this.Street;
                if (address != null && address.Length > 0)
                {
                    address += ", ";
                }

                return address + this.PostalCode + " " + this.Town;
            }
        }

        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 += "Fax: " + 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 += "Internet: " + this.Communication4;
                }
                return info;
            }
            set { }
        }

        public string DetailDescription
        {
            get
            {
                return this.Name;
            }
        }

        public string FilterRelevants
        {
            get
            {
                return this.Name;
            }
        }

        public string IconPath
        {
            get
            {
                return @"..\..\Ressources\Icons\OfficeBulidingBlackDisabled.png";
            }
        }

        public string ServiceUnitName
        {
            get
            {
                if (this.CostRatePeriods != null)
                {
                    return CostRatePeriods.GetCurrentlyValidRate(CostRatePeriodType.MinutesPerServiceUnit).UnitName;
                }

                return "Stunden";
            }
        }

        public string SimpleDescription
        {
            get
            {
                return this.Name;
            }
        }

        public bool SupportsActivationType
        {
            get
            {
                return false;
            }
        }

        public long Version
        {
            get
            {
                return this.OrganisationVersion;
            }

            set
            {
                this.OrganisationVersion = value;
            }
        }

        public override bool Equals(object obj)
        {
            if (obj is CompactOrganisationDC)
            {
                return this.OrganisationOid == ((CompactOrganisationDC)obj).OrganisationOid;
            }

            return false;
        }

        public override int GetHashCode()
        {
            return this.GetType().Name.GetHashCode() ^ this.OrganisationOid.GetHashCode();
        }

        public override string ToString()
        {
            return this.Name;
        }
    }
}