using BS.Shared.DataContracts;
using BeWo.Validation;

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

		public static string PropertyName_Notice = "Notice";

		private string _Name;

		private string _Notice;

		public AdditionalServiceVM(AdditionalServiceDC pDataContract) : base(pDataContract, pDataContract.AdditionalServiceOid == null)
		{
		}

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

			set
			{
				if (!AreDifferent(_Name, value))
					return;

				_Name = value;
				StoreDirtyInformation(AreDifferent(DataContract.Name, value), PropertyName_Name);
				FirePropertyChanged(PropertyName_Name);
			}
		}

		public string Notice
		{
			get { return _Notice; }

			set
			{
				if (!AreDifferent(_Notice, value))
					return;

				_Notice = value;
				StoreDirtyInformation(AreDifferent(DataContract.Notice, value), PropertyName_Notice);
				FirePropertyChanged(PropertyName_Notice);
			}
		}

		protected override void InitByDataContract(AdditionalServiceDC pDataContract)
		{
			if (!IsNew)
			{
				_Name = pDataContract.Name;
				_Notice = pDataContract.Notice;
			}
		}

		protected override AdditionalServiceDC MapToDataContract(AdditionalServiceDC pDataContract, bool doCommit)
		{
			pDataContract.Name = _Name;
			pDataContract.Notice = _Notice;

			return pDataContract;
		}
	}
}