85 lines
2.7 KiB
C#
85 lines
2.7 KiB
C#
using System.Windows.Media;
|
|
|
|
using BeWo.Validation;
|
|
|
|
using BS.Shared.DataContracts;
|
|
using BS.Shared.Extensions;
|
|
|
|
namespace BeWo.ViewModel
|
|
{
|
|
public class AppointmentCategoryVM : AbstractDCMapperVM<AppointmentCategoryDC>
|
|
{
|
|
public static string PropertyName_Brush = "Brush";
|
|
|
|
public static string PropertyName_DisplayName = "DisplayName";
|
|
|
|
private SolidColorBrush _Brush;
|
|
|
|
private string _BrushString;
|
|
|
|
private string _DisplayName;
|
|
|
|
public AppointmentCategoryVM(AppointmentCategoryDC pDataContract)
|
|
: base(pDataContract, pDataContract.AppointmentCategoryOid == null)
|
|
{
|
|
}
|
|
|
|
public bool IsDeleteable
|
|
{
|
|
get { return true; }
|
|
}
|
|
|
|
[Validation(ValidationRule = ValidationRules.NotNullOrStringEmpty)]
|
|
public SolidColorBrush Brush
|
|
{
|
|
get { return this._Brush; }
|
|
|
|
set
|
|
{
|
|
if (this.AreDifferent(this._Brush, value))
|
|
{
|
|
this._Brush = value;
|
|
this._BrushString = value.ToStringNullCheck();
|
|
this.StoreDirtyInformation(this.AreDifferent(this.DataContract.Color, value.ToString()), PropertyName_Brush);
|
|
this.FirePropertyChanged(PropertyName_Brush);
|
|
}
|
|
}
|
|
}
|
|
|
|
[ValidationAttribute(ValidationRule = ValidationRules.NotNullOrStringEmpty)]
|
|
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);
|
|
}
|
|
}
|
|
}
|
|
|
|
protected override void InitByDataContract(AppointmentCategoryDC pDataContract)
|
|
{
|
|
if (!this.IsNew)
|
|
{
|
|
this._DisplayName = pDataContract.DisplayName;
|
|
if (!string.IsNullOrEmpty(pDataContract.Color))
|
|
{
|
|
this.Brush = (SolidColorBrush)new BrushConverter().ConvertFrom(pDataContract.Color);
|
|
}
|
|
}
|
|
}
|
|
|
|
protected override AppointmentCategoryDC MapToDataContract(AppointmentCategoryDC pDataContract, bool doCommit)
|
|
{
|
|
pDataContract.DisplayName = this._DisplayName;
|
|
pDataContract.Color = this._BrushString;
|
|
|
|
return pDataContract;
|
|
}
|
|
}
|
|
} |