using BS.Shared.DataContracts;

namespace BeWo.ViewModel
{
    public class InvoiceNumberVM : AbstractDCMapperVM<InvoiceNumberDC>
    {
        #region Constants and Fields

        public static string PropertyName_CurrentNumber = "CurrentNumber";

        public static string PropertyName_Pattern = "Pattern";

        public static string PropertyName_Use = "Use";

        private long _CurrentNumber;

        private string _Pattern;

        private bool _Use;

        #endregion

        #region Constructors and Destructors

        public InvoiceNumberVM(InvoiceNumberDC pDC) : base(pDC, !pDC.InvoiceNumberOid.HasValue) {}

        #endregion

        #region Properties

        public long CurrentNumber
        {
            get
            {
                return this._CurrentNumber;
            }

            set
            {
                if (this.AreDifferent(this._CurrentNumber, value))
                {
                    this._CurrentNumber = value;
                    this.StoreDirtyInformation(this.AreDifferent(this.DataContract.CurrentNumber, value), PropertyName_CurrentNumber);
                    this.FirePropertyChanged(PropertyName_CurrentNumber);
                }
            }
        }

        public string Pattern
        {
            get
            {
                return this._Pattern;
            }

            set
            {
                if (this.AreDifferent(this._Pattern, value))
                {
                    this._Pattern = value;
                    this.StoreDirtyInformation(this.AreDifferent(this.DataContract.Pattern, value), PropertyName_Pattern);
                    this.FirePropertyChanged(PropertyName_Pattern);
                }
            }
        }

        public bool Use
        {
            get
            {
                return this._Use;
            }

            set
            {
                if (this.AreDifferent(this._Use, value))
                {
                    this._Use = value;
                    this.StoreDirtyInformation(this.AreDifferent(this.DataContract.Use, value), PropertyName_Use);
                    this.FirePropertyChanged(PropertyName_Use);
                }
            }
        }

        #endregion

        #region Methods

        protected override void InitByDataContract(InvoiceNumberDC pDataContract)
        {
            this._Use = pDataContract.Use;
            this._CurrentNumber = pDataContract.CurrentNumber;
            this._Pattern = pDataContract.Pattern;
        }

        protected override InvoiceNumberDC MapToDataContract(InvoiceNumberDC pDataContract, bool doCommit)
        {
            pDataContract.CurrentNumber = this._CurrentNumber;
            pDataContract.Pattern = this._Pattern;
            pDataContract.Use = this._Use;
            return this.DataContract;
        }

        #endregion
    }
}