114 lines
3.3 KiB
C#
114 lines
3.3 KiB
C#
using System;
|
|
|
|
using BeWo.Validation;
|
|
|
|
using BS.Shared.DataContracts;
|
|
using BS.Shared.DataContracts.Compact;
|
|
using DevExpress.Xpf.Core;
|
|
|
|
namespace BeWo.ViewModel
|
|
{
|
|
public class NewsItemVM : AbstractDCMapperVM<NewsItemDC>
|
|
{
|
|
public static string PropertyName_PublishDate = "PublishDate";
|
|
|
|
public static string PropertyName_Text = "Text";
|
|
|
|
public static string PropertyName_Title = "Title";
|
|
|
|
public static string PropertyName_Team = "Team";
|
|
|
|
private DateTime? _PublishDate;
|
|
|
|
private string _Text;
|
|
|
|
private string _Title;
|
|
|
|
private CompactTeamDC _Team;
|
|
|
|
public NewsItemVM(NewsItemDC pDC) : base(pDC, !pDC.NewsItemOid.HasValue)
|
|
{
|
|
}
|
|
|
|
[Validation(ValidationRule = ValidationRules.NotNullOrStringEmpty)]
|
|
public DateTime? PublishDate
|
|
{
|
|
get { return this._PublishDate; }
|
|
|
|
set
|
|
{
|
|
if (this.AreDifferent(this._PublishDate, value))
|
|
{
|
|
this._PublishDate = value;
|
|
this.StoreDirtyInformation(this.AreDifferent(this.DataContract.PublishDate, value), PropertyName_PublishDate);
|
|
this.FirePropertyChanged(PropertyName_PublishDate);
|
|
}
|
|
}
|
|
}
|
|
|
|
[ValidationAttribute(ValidationRule = ValidationRules.NotNullOrStringEmpty)]
|
|
public string Text
|
|
{
|
|
get { return this._Text; }
|
|
|
|
set
|
|
{
|
|
if (this.AreDifferent(this._Text, value))
|
|
{
|
|
this._Text = value;
|
|
this.StoreDirtyInformation(this.AreDifferent(this.DataContract.Text, value), PropertyName_Text);
|
|
this.FirePropertyChanged(PropertyName_Text);
|
|
}
|
|
}
|
|
}
|
|
|
|
[ValidationAttribute(ValidationRule = ValidationRules.NotNullOrStringEmpty)]
|
|
public string Title
|
|
{
|
|
get { return this._Title; }
|
|
|
|
set
|
|
{
|
|
if (this.AreDifferent(this._Title, value))
|
|
{
|
|
this._Title = value;
|
|
this.StoreDirtyInformation(this.AreDifferent(this.DataContract.Title, value), PropertyName_Title);
|
|
this.FirePropertyChanged(PropertyName_Title);
|
|
}
|
|
}
|
|
}
|
|
|
|
public CompactTeamDC Team
|
|
{
|
|
get { return this._Team; }
|
|
|
|
set
|
|
{
|
|
if (this.AreDifferent(this._Team, value))
|
|
{
|
|
this._Team = value;
|
|
this.StoreDirtyInformation(this.AreDifferent(this.DataContract.Team, value), PropertyName_Team);
|
|
this.FirePropertyChanged(PropertyName_Team);
|
|
}
|
|
}
|
|
}
|
|
|
|
protected override void InitByDataContract(NewsItemDC pDataContract)
|
|
{
|
|
this._PublishDate = pDataContract.PublishDate;
|
|
this._Text = pDataContract.Text;
|
|
this._Title = pDataContract.Title;
|
|
this._Team = pDataContract.Team;
|
|
}
|
|
|
|
protected override NewsItemDC MapToDataContract(NewsItemDC pDataContract, bool doCommit)
|
|
{
|
|
pDataContract.PublishDate = this._PublishDate;
|
|
pDataContract.Text = this._Text;
|
|
pDataContract.Title = this._Title;
|
|
pDataContract.Team = _Team;
|
|
|
|
return pDataContract;
|
|
}
|
|
}
|
|
} |