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

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

		public static string PropertyName_Notice = "Notice";

		public static string PropertyName_AdditionalService = "AdditionalService";

		private AdditionalServiceDC _AdditionalService;

		private string _Name;

		private string _Notice;

		public AdditionalServiceRegionVM(AdditionalServiceRegionDC pDataContract) : base(pDataContract, pDataContract.AdditionalServiceRegionOid == 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.Name, value), PropertyName_Notice);
				FirePropertyChanged(PropertyName_Notice);
			}
		}

		[Validation(ValidationRule = ValidationRules.NotNullOrStringEmpty)]
		public AdditionalServiceDC AdditionalService
		{
			get { return _AdditionalService; }

			set
			{
				if (!AreDifferent(_AdditionalService, value)) return;
				_AdditionalService = value;
				StoreDirtyInformation(AreDifferent(DataContract.AdditionalService, value), PropertyName_AdditionalService);
				FirePropertyChanged(PropertyName_AdditionalService);
			}
		}

		protected override void InitByDataContract(AdditionalServiceRegionDC pDataContract)
		{
			if (IsNew) return;
			_Name = pDataContract.Name;
			_Notice = pDataContract.Notice;
			_AdditionalService = pDataContract.AdditionalService;
		}

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

			return pDataContract;
		}
	}
}