using BeWo.Core.Service;
using BeWo.Validation;

using BS.Shared;
using BS.Shared.DataContracts;

namespace BeWo.ViewModel
{
    public class EmploymentTypeVM : AbstractDCMapperVM<EmploymentTypeDC>
    {
        public static string PropertyName_Name = "Name";

        private string _Name;

        public EmploymentTypeVM(EmploymentTypeDC pDC) : base(pDC, pDC.EmploymentTypeOid == null)
        {
        }

        [Validation(ValidationRule = ValidationRules.NotNullOrStringEmpty)]
        public string Name
        {
            get { return this._Name; }

            set
            {
                if (this.AreDifferent(this._Name, value))
                {
                    this._Name = value;
                    this.StoreDirtyInformation(this.AreDifferent(this.DataContract.Name, value), PropertyName_Name);
                    this.FirePropertyChanged(PropertyName_Name);
                }
            }
        }



        protected override void InitByDataContract(EmploymentTypeDC pDataContract)
        {
            if (!this.IsNew)
            {
                this._Name = pDataContract.Name;
            }
        }

        protected override EmploymentTypeDC MapToDataContract(EmploymentTypeDC pDataContract, bool doCommit)
        {
            pDataContract.Name = this._Name;
            return pDataContract;
        }
    }
}