111 lines
3.6 KiB
C#
111 lines
3.6 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
using BS.Shared.DataContracts;
|
|
|
|
namespace BeWo.ViewModel
|
|
{
|
|
public class AssessmentSheetCategoryVM : AbstractDCMapperVM<AssessmentSheetCategoryDC>
|
|
{
|
|
public static string PropertyName_Description = "Description";
|
|
|
|
public static string PropertyName_Position = "Position";
|
|
|
|
public static string PropertyName_Values = "Values";
|
|
|
|
private string _Description;
|
|
|
|
private int _Position;
|
|
|
|
private List<AssessmentSheetValueDC> _Values;
|
|
|
|
public AssessmentSheetCategoryVM(AssessmentSheetCategoryDC pDC) : base(pDC, pDC.AssessmentSheetCategoryOid == null)
|
|
{
|
|
}
|
|
|
|
public string Description
|
|
{
|
|
get { return this._Description; }
|
|
|
|
set
|
|
{
|
|
if (this.AreDifferent(this._Description, value))
|
|
{
|
|
this._Description = value;
|
|
this.StoreDirtyInformation(this.AreDifferent(this.DataContract.Description, value), PropertyName_Description);
|
|
this.FirePropertyChanged(PropertyName_Description);
|
|
}
|
|
}
|
|
}
|
|
|
|
public int Position
|
|
{
|
|
get { return this._Position; }
|
|
|
|
set
|
|
{
|
|
if (this.AreDifferent(this._Position, value))
|
|
{
|
|
this._Position = value;
|
|
this.StoreDirtyInformation(this.AreDifferent(this.DataContract.Position, value), PropertyName_Position);
|
|
this.FirePropertyChanged(PropertyName_Position);
|
|
}
|
|
}
|
|
}
|
|
|
|
public List<AssessmentSheetValueDC> Values
|
|
{
|
|
get { return this._Values; }
|
|
|
|
set
|
|
{
|
|
if (this.AreDifferent(this._Values, value))
|
|
{
|
|
this._Values = value;
|
|
this.StoreDirtyInformation(this.AreDifferent(this.DataContract.PossibleValues, value), PropertyName_Values);
|
|
this.FirePropertyChanged(PropertyName_Values);
|
|
}
|
|
}
|
|
}
|
|
|
|
public string ValuesString
|
|
{
|
|
get { return this._Values != null ? string.Join(" | ", this.Values.Select(v => v.Description).ToArray()) : string.Empty; }
|
|
}
|
|
|
|
public static int Compare(AssessmentSheetCategoryVM x, AssessmentSheetCategoryVM y)
|
|
{
|
|
if (x.Position.Equals(y.Position))
|
|
{
|
|
return Comparer<string>.Default.Compare(x.Description, y.Description);
|
|
}
|
|
|
|
return x.Position.CompareTo(y.Position);
|
|
}
|
|
|
|
public static int Compare(AssessmentSheetCategoryDC x, AssessmentSheetCategoryDC y)
|
|
{
|
|
if (x.Position.Equals(y.Position))
|
|
{
|
|
return Comparer<string>.Default.Compare(x.Description, y.Description);
|
|
}
|
|
|
|
return x.Position.CompareTo(y.Position);
|
|
}
|
|
|
|
protected override void InitByDataContract(AssessmentSheetCategoryDC pDataContract)
|
|
{
|
|
this._Description = pDataContract.Description;
|
|
this._Values = pDataContract.PossibleValues;
|
|
this._Position = pDataContract.Position;
|
|
}
|
|
|
|
protected override AssessmentSheetCategoryDC MapToDataContract(AssessmentSheetCategoryDC pDataContract, bool doCommit)
|
|
{
|
|
pDataContract.Description = this._Description;
|
|
pDataContract.PossibleValues = this._Values;
|
|
pDataContract.Position = this._Position;
|
|
return pDataContract;
|
|
}
|
|
}
|
|
} |