using System;
using System.Collections.Generic;

using BS.Shared;
using BS.Shared.Core;

namespace BeWo.Data.Entities
{
    public class CostBearer2SupportConcept : BeWoEntityBase
    {
        // public static string PropertyName_HourlyRate = "HourlyRate";
        // public static string PropertyName_RateFactor = "RateFactor";
        #region Constants and Fields

        public static string PropertyName_AccountingTransactions = "AccountingTransactions";

        public static string PropertyName_ApprovalPeriodList = "ApprovalPeriodList";

        public static string PropertyName_ApprovedEndDate = "ApprovedEndDate";

        // public static string PropertyName_ApprovedFLS = "ApprovedFLS";

        // public static string PropertyName_ApprovedFLSTotal = "ApprovedFLSTotal";
        public static string PropertyName_ApprovedStartDate = "ApprovedStartDate";

        public static string PropertyName_CostBearer = "CostBearer";

        public static string PropertyName_CostBearerContactPerson = "CostBearerContactPerson";

        public static string PropertyName_CustomerReferenceNumber = "CustomerReferenceNumber";

        public static string PropertyName_AuswahlBezeichnung = "AuswahlBezeichnung";

        public static string PropertyName_MonthlyPayment = "MonthlyPayment";

        public static string PropertyName_RequestedEndDate = "RequestedEndDate";

        public static string PropertyName_RequestedStartDate = "RequestedStartDate";

        public static string PropertyName_ServiceRecord = "ServiceRecord";

        public static string PropertyName_Status = "Status";

        public static string PropertyName_SupportConcept = "SupportConcept";

        private IList<AccountingTransaction> _AccountingTransactions;

        private IList<SupportConceptApprovalPeriod> _ApprovalPeriodList;

        private DateTime? _ApprovedEndDate;

        // private decimal? _ApprovedFLS;

        // private decimal? _ApprovedFLSTotal;
        private DateTime? _ApprovedStartDate;

        private CostBearer _CostBearer;

        private Person _CostBearerContactPerson;

        private string _CustomerReferenceNumber;

        private string _AuswahlBezeichnung;

        private decimal? _MonthlyPayment;

        private DateTime? _RequestedEndDate;

        private DateTime? _RequestedStartDate;

        private IList<ServiceRecord> _ServiceRecords;

        private CostBearer2SupportConceptStatus _Status;

        private SupportConcept _SupportConcept;

        #endregion

        #region Constructors and Destructors

        public CostBearer2SupportConcept()
        {
            this._Tid = TableID.CostBearer2SupportConcept;
        }

        #endregion

        #region Properties

        public virtual IList<AccountingTransaction> AccountingTransactions
        {
            get
            {
                return this._AccountingTransactions;
            }

            set
            {
                if (this.AreDifferent(this._AccountingTransactions, value))
                {
                    this._AccountingTransactions = value;
                }
            }
        }

        public virtual IList<SupportConceptApprovalPeriod> ApprovalPeriodList
        {
            get
            {
                return this._ApprovalPeriodList ?? (this._ApprovalPeriodList = new List<SupportConceptApprovalPeriod>());
            }

            set
            {
                if (this.AreDifferent(this._ApprovalPeriodList, value))
                {
                    this._ApprovalPeriodList = value;
                }
            }
        }

        public virtual DateTime? ApprovedEndDate
        {
            get
            {
                return this._ApprovedEndDate;
            }

            set
            {
                if (this.AreDifferent(this._ApprovedEndDate, value))
                {
                    this._ApprovedEndDate = value;
                }
            }
        }

        // public virtual decimal? ApprovedFLS
        // {
        // get
        // {
        // return this._ApprovedFLS;
        // }

        // set
        // {
        // if (this.AreDifferent(this._ApprovedFLS, value))
        // {
        // this._ApprovedFLS = value;
        // }
        // }
        // }

        // public virtual decimal? ApprovedFLSTotal
        // {
        // get
        // {
        // return this._ApprovedFLSTotal;
        // }

        // set
        // {
        // if (this.AreDifferent(this._ApprovedFLSTotal, value))
        // {
        // this._ApprovedFLSTotal = value;
        // }
        // }
        // }

        public virtual DateTime? ApprovedStartDate
        {
            get
            {
                return this._ApprovedStartDate;
            }

            set
            {
                if (this.AreDifferent(this._ApprovedStartDate, value))
                {
                    this._ApprovedStartDate = value;
                }
            }
        }

        public virtual CostBearer CostBearer
        {
            get
            {
                return this._CostBearer;
            }

            set
            {
                if (this.AreDifferent(this._CostBearer, value))
                {
                    this._CostBearer = value;
                }
            }
        }

        public virtual Person CostBearerContactPerson
        {
            get
            {
                return this._CostBearerContactPerson;
            }

            set
            {
                if (this.AreDifferent(this._CostBearerContactPerson, value))
                {
                    this._CostBearerContactPerson = value;
                }
            }
        }

        public virtual string CustomerReferenceNumber
        {
            get
            {
                return this._CustomerReferenceNumber;
            }

            set
            {
                if (this.AreDifferent(this._CustomerReferenceNumber, value))
                {
                    this._CustomerReferenceNumber = value;
                }
            }
        }

        public virtual string AuswahlBezeichnung
        {
            get
            {
                return this._AuswahlBezeichnung;
            }

            set
            {
                if (this.AreDifferent(this._AuswahlBezeichnung, value))
                {
                    this._AuswahlBezeichnung = value;
                }
            }
        }

        public virtual decimal? MonthlyPayment
        {
            get
            {
                return this._MonthlyPayment;
            }

            set
            {
                if (this.AreDifferent(this._MonthlyPayment, value))
                {
                    this._MonthlyPayment = value;
                }
            }
        }

        public virtual DateTime? RequestedEndDate
        {
            get
            {
                return this._RequestedEndDate;
            }

            set
            {
                if (this.AreDifferent(this._RequestedEndDate, value))
                {
                    this._RequestedEndDate = value;
                }
            }
        }

        public virtual DateTime? RequestedStartDate
        {
            get
            {
                return this._RequestedStartDate;
            }

            set
            {
                if (this.AreDifferent(this._RequestedStartDate, value))
                {
                    this._RequestedStartDate = value;
                }
            }
        }

        public virtual IList<ServiceRecord> ServiceRecords
        {
            get
            {
                return this._ServiceRecords ?? (this._ServiceRecords = new List<ServiceRecord>());
            }

            set
            {
                if (this.AreDifferent(this._ServiceRecords, value))
                {
                    this._ServiceRecords = value;
                }
            }
        }

        public virtual CostBearer2SupportConceptStatus Status
        {
            get
            {
                return this._Status;
            }

            set
            {
                if (this.AreDifferent(this._Status, value))
                {
                    this._Status = value;
                }
            }
        }

        public virtual SupportConcept SupportConcept
        {
            get
            {
                return this._SupportConcept;
            }

            set
            {
                if (this.AreDifferent(this._SupportConcept, value))
                {
                    this._SupportConcept = value;
                }
            }
        }

        #endregion

        #region Public Methods

        public virtual DateTime? StartDate
        {
            get
            {
                if (ApprovedStartDate.HasValue)
                    return ApprovedStartDate;
                if (RequestedStartDate.HasValue)
                    return RequestedStartDate;
                return DateTime.MinValue;
            }
        }

        public virtual DateTime? EndDate
        {
            get
            {
                if (ApprovedEndDate.HasValue)
                    return ApprovedEndDate;
                if (RequestedEndDate.HasValue)
                    return RequestedEndDate;
                return DateTime.MaxValue;
            }
        }

        public virtual DateTimeSpan GetApprovedSpan()
        {
            if (this.ApprovedEndDate.HasValue && this.ApprovedStartDate.HasValue)
            {
                DateTimeSpan dts = new DateTimeSpan();
                dts.StartDateTime = this.ApprovedStartDate.Value.Date;
                dts.EndDateTime = this.ApprovedEndDate.Value.Date;
                dts.EndDateTime = new DateTime(dts.EndDateTime.Year, dts.EndDateTime.Month, dts.EndDateTime.Day, 23, 59, 59);

                return dts;
            }

            return null;
        }

        public virtual DateTimeSpan GetRequestedSpan()
        {
            if (this.RequestedEndDate.HasValue && this.RequestedStartDate.HasValue)
            {
                DateTimeSpan dts = new DateTimeSpan();
                dts.StartDateTime = this.RequestedStartDate.Value.Date;
                dts.EndDateTime = this.RequestedEndDate.Value.Date;
                dts.EndDateTime = new DateTime(dts.EndDateTime.Year, dts.EndDateTime.Month, dts.EndDateTime.Day, 23, 59, 59);

                return dts;
            }

            return null;
        }

        #endregion
    }
}