using System; using System.Collections.Generic; using BeWo.Core; using BeWo.Validation; using BeWo.ViewModel.ListViewModel; using BS.Shared; using BS.Shared.DataContracts; using BS.Shared.Extensions; namespace BeWo.ViewModel { public class RatingVM : AbstractDCMapperVM { public static string PropertyName_GoalRatingList = "GoalRatingList"; public static string PropertyName_StartDate = "StartDate"; public static string PropertyName_DisplayName = "DisplayName"; public static string PropertyName_RatingId = "RatingId"; public static string PropertyName_Notice = "Notice"; public static string PropertyName_RTFNotice = "RTFNotice"; private GoalRatingListVM _GoalRatingList; private DateTime? _StartDate; private String _DisplayName; private int? _RatingId; private String _Notice; private String _RTFNotice; public RatingVM(RatingDC pDC) : base(pDC, pDC.RatingOid == null) { } public GoalRatingListVM GoalRatingList { get { return _GoalRatingList; } } public DateTime? StartDate { get { return this._StartDate; } set { if (this.AreDifferent(this._StartDate, value)) { this._StartDate = value; this.StoreDirtyInformation(this.AreDifferent(this.DataContract.StartDate, value), PropertyName_StartDate); this.FirePropertyChanged(PropertyName_StartDate); } } } public string DisplayName { get { return this._DisplayName; } set { if (this.AreDifferent(this._DisplayName, value)) { this._DisplayName = value; this.StoreDirtyInformation(this.AreDifferent(this.DataContract.DisplayName, value), PropertyName_DisplayName); this.FirePropertyChanged(PropertyName_DisplayName); } } } public string Notice { get { return this._Notice; } set { if (this.AreDifferent(this._Notice, value)) { this._Notice = value; this.StoreDirtyInformation(this.AreDifferent(this.DataContract.Notice, value), PropertyName_Notice); this.FirePropertyChanged(PropertyName_Notice); } } } public string RTFNotice { get { return _RTFNotice; } set { if (AreDifferent(_RTFNotice, value)) { _RTFNotice = value; StoreDirtyInformation(AreDifferent(DataContract.RTFNotice, value), PropertyName_RTFNotice); FirePropertyChanged(PropertyName_RTFNotice); } } } public int? RatingId { get { return this._RatingId; } set { if (this.AreDifferent(this._RatingId, value)) { this._RatingId = value; this.StoreDirtyInformation(this.AreDifferent(this.DataContract.RatingId, value), PropertyName_RatingId); this.FirePropertyChanged(PropertyName_RatingId); } } } public override bool IsDirty { get { if (this.GoalRatingList == null) { return false; } return base.IsDirty || this.GoalRatingList.IsDirty; } } protected override void InitByDataContract(RatingDC pDataContract) { this._StartDate = pDataContract.StartDate; this._DisplayName = pDataContract.DisplayName; this._RatingId = pDataContract.RatingId; this._Notice = pDataContract.Notice; this._RTFNotice = pDataContract.RTFNotice; _GoalRatingList = VMFactory.CreateGoalRatingListVM(pDataContract.GoalRatingList); // new GoalRatingListVM(pDataContract.GoalRatingList, VMFactory.CreateGoalRatingListVM()); } protected override RatingDC MapToDataContract(RatingDC pDataContract, bool doCommit) { pDataContract.StartDate = _StartDate; pDataContract.DisplayName = _DisplayName; pDataContract.RatingId = _RatingId; pDataContract.Notice = _Notice; pDataContract.RTFNotice = _RTFNotice; pDataContract.GoalRatingList = this.GoalRatingList.CopyToDCList(doCommit); return pDataContract; } } }