using System;
using System.Collections.Generic;
using System.Runtime.Serialization;

using BS.Shared.Core;

namespace BS.Shared.DataContracts
{
    [DataContract]
    public class PersonDC : IDataContract
    {
        private List<ContactDC> _ContactInformations;

        [DataMember]
        public string Abbreviation { get; set; }

        [DataMember]
        public string AccountNumber { get; set; }

        [DataMember]
        public ActivationTypeId ActivationType { get; set; }

        [DataMember]
        public long? AddressOid { get; set; }

        [DataMember]
        public long? AddressVersion { get; set; }

        [DataMember]
        public long? BankAccountOid { get; set; }

        [DataMember]
        public long? BankAccountVersion { get; set; }

        [DataMember]
        public string BankCode { get; set; }

        [DataMember]
        public string BankName { get; set; }

        [DataMember]
        public string Bic { get; set; }

        [DataMember]
        public List<ContactDC> ContactInformations
        {
            get
            {
                if (this._ContactInformations == null)
                {
                    this._ContactInformations = new List<ContactDC>();
                }

                return this._ContactInformations;
            }

            set
            {
                this._ContactInformations = value;
            }
        }

        [DataMember]
        public DateTime? DateOfBirth { get; set; }

        [DataMember]
        public FamilyStatus? FamilyStatus { get; set; }

        [DataMember]
        public string FirstName { get; set; }

        [DataMember]
        public ValueListEntryDC Function { get; set; }

        [DataMember]
        public string IBAN { get; set; }

        [DataMember]
        public string InvoiceAddressLine1 { get; set; }

        [DataMember]
        public string InvoiceAddressLine2 { get; set; }

        [DataMember]
        public long? InvoiceAddressOid { get; set; }

        [DataMember]
        public string InvoiceAddressPostalCode { get; set; }

        [DataMember]
        public string InvoiceAddressStreet { get; set; }

        [DataMember]
        public string InvoiceAddressTown { get; set; }

        [DataMember]
        public long? InvoiceAddressVersion { get; set; }

        [DataMember]
        public string LastName { get; set; }

        [DataMember]
        public List<Organisation2PersonDC> OrganisationRelations { get; set; }

        [DataMember]
        public string PersonNotice { get; set; }

        [DataMember]
        public long? PersonOid { get; set; }

        [DataMember]
        public long? PersonVersion { get; set; }

        [DataMember]
        public string PostalCode { get; set; }

        [DataMember]
        public string Profession { get; set; }

        [DataMember]
        public Sex? Sex { get; set; }

        [DataMember]
        public string AddressLine1 { get; set; }

		[DataMember]
		public string Street { get; set; }

        [DataMember]
        public ValueListEntryDC Title { get; set; }

        [DataMember]
        public string Town { get; set; }

        [DataMember]
        public List<VarFieldDC> VarFields { get; set; }

        public bool ContainsAddressData()
        {
			return !Utils.AreAllNullOrEmpty(this.AddressLine1, this.Street, this.PostalCode, this.Town);
        }

        public bool ContainsBankAccountData()
        {
            return !Utils.AreAllNullOrEmpty(this.BankCode, this.BankName, this.AccountNumber, this.IBAN, this.Bic);
        }

        public bool ContainsInvoiceAddressData()
        {
            return !Utils.AreAllNullOrEmpty(this.InvoiceAddressStreet, this.InvoiceAddressPostalCode, this.InvoiceAddressTown, this.InvoiceAddressLine1, this.InvoiceAddressLine2);
        }

        public bool ContainsPersonData()
        {
            return !Utils.AreAllNullOrEmpty(this.FirstName, this.LastName, this.DateOfBirth, this.Sex, this.Profession, this.Abbreviation);
        }
    }
}