2016-06-27 01:45:38 +02:00
|
|
|
|
using System.Collections.ObjectModel;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
|
|
|
|
using BeWo.Validation;
|
2020-08-17 15:50:00 +02:00
|
|
|
|
using BeWo.ViewModel.ListViewModel;
|
2016-06-27 01:45:38 +02:00
|
|
|
|
using BS.Shared.DataContracts;
|
|
|
|
|
|
using BS.Shared.DataContracts.Compact;
|
|
|
|
|
|
using BS.Shared.Extensions;
|
|
|
|
|
|
|
|
|
|
|
|
namespace BeWo.ViewModel
|
|
|
|
|
|
{
|
|
|
|
|
|
public class TeamVM : AbstractDCMapperVM<TeamDC>
|
|
|
|
|
|
{
|
|
|
|
|
|
public static string PropertyName_Leader = "Leader";
|
|
|
|
|
|
|
|
|
|
|
|
public static string PropertyName_LeaderString = "LeaderString";
|
|
|
|
|
|
|
|
|
|
|
|
public static string PropertyName_Member = "Member";
|
|
|
|
|
|
|
|
|
|
|
|
public static string PropertyName_Name = "Name";
|
|
|
|
|
|
|
|
|
|
|
|
public static string PropertyName_Notice = "Notice";
|
|
|
|
|
|
|
2020-08-17 15:50:00 +02:00
|
|
|
|
public static string PropertyName_VarFields = "VarFields";
|
|
|
|
|
|
|
2016-06-27 01:45:38 +02:00
|
|
|
|
private CompactEmployeeDC _Leader;
|
|
|
|
|
|
|
|
|
|
|
|
private ObservableCollection<CompactEmployeeDC> _Member;
|
|
|
|
|
|
|
2025-10-06 11:07:54 +02:00
|
|
|
|
private ObservableCollection<Person2TeamDC> _OwnChatMember;
|
|
|
|
|
|
|
|
|
|
|
|
private bool _IsOwnChatTeam;
|
|
|
|
|
|
|
2016-06-27 01:45:38 +02:00
|
|
|
|
private string _Name;
|
|
|
|
|
|
|
|
|
|
|
|
private string _Notice;
|
|
|
|
|
|
|
2020-08-17 15:50:00 +02:00
|
|
|
|
private VarFieldListVM _VarFields;
|
|
|
|
|
|
|
2016-06-27 01:45:38 +02:00
|
|
|
|
public TeamVM(TeamDC pDataContract) : base(pDataContract, pDataContract.TeamOid == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-08-17 15:50:00 +02:00
|
|
|
|
public override bool IsDirty
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return base.IsDirty || (_VarFields != null && _VarFields.IsDirty);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-10-06 11:07:54 +02:00
|
|
|
|
public bool IsOwnChatTeam
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return _IsOwnChatTeam; }
|
|
|
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
if (AreDifferent(_IsOwnChatTeam, value))
|
|
|
|
|
|
{
|
|
|
|
|
|
_IsOwnChatTeam = value;
|
|
|
|
|
|
StoreDirtyInformation(AreDifferent(DataContract.IsOwnChatTeam, value), nameof(IsOwnChatTeam));
|
|
|
|
|
|
FirePropertyChanged(nameof(IsOwnChatTeam));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2016-06-27 01:45:38 +02:00
|
|
|
|
public CompactEmployeeDC Leader
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return this._Leader; }
|
|
|
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
if (this.AreDifferent(this._Leader, value))
|
|
|
|
|
|
{
|
|
|
|
|
|
this._Leader = value;
|
|
|
|
|
|
|
|
|
|
|
|
bool lSame = (this.DataContract.Leader == null && value == null) || (this.DataContract.Leader != null && value != null && this.DataContract.Leader.EmployeeOid == value.EmployeeOid);
|
|
|
|
|
|
this.StoreDirtyInformation(!lSame, PropertyName_Leader);
|
|
|
|
|
|
this.FirePropertyChanged(PropertyName_Leader);
|
|
|
|
|
|
this.FirePropertyChanged(PropertyName_LeaderString);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-10-24 01:49:21 +02:00
|
|
|
|
|
2016-06-27 01:45:38 +02:00
|
|
|
|
public string LeaderString
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return this._Leader.ToStringNullCheck(); } // Validation Workaround
|
|
|
|
|
|
set { }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public ObservableCollection<CompactEmployeeDC> Member
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return this._Member; }
|
|
|
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
if (this.AreDifferent(this._Member, value))
|
|
|
|
|
|
{
|
|
|
|
|
|
this._Member = value;
|
|
|
|
|
|
this.FirePropertyChanged(PropertyName_Member);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-10-06 11:07:54 +02:00
|
|
|
|
public ObservableCollection<Person2TeamDC> OwnChatMember
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return this._OwnChatMember; }
|
|
|
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
if (this.AreDifferent(this._OwnChatMember, value))
|
|
|
|
|
|
{
|
|
|
|
|
|
this._OwnChatMember = value;
|
|
|
|
|
|
this.FirePropertyChanged(nameof(OwnChatMember));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-10-24 01:49:21 +02:00
|
|
|
|
public void OwnChatMemberRoleChanged(bool changed)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.StoreDirtyInformation(changed, "OwnChatMemberRole");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2016-06-27 01:45:38 +02:00
|
|
|
|
[ValidationAttribute(ValidationRule = ValidationRules.NotNullOrStringEmpty)]
|
|
|
|
|
|
public string Name
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return this._Name; }
|
|
|
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
if (this.AreDifferent(this._Name, value))
|
|
|
|
|
|
{
|
|
|
|
|
|
this._Name = value;
|
|
|
|
|
|
this.StoreDirtyInformation(this.DataContract.Name != value, PropertyName_Name);
|
|
|
|
|
|
this.FirePropertyChanged(PropertyName_Name);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public string Notice
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return this._Notice; }
|
|
|
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
if (this.AreDifferent(this._Notice, value))
|
|
|
|
|
|
{
|
|
|
|
|
|
this._Notice = value;
|
|
|
|
|
|
this.StoreDirtyInformation(this.DataContract.Notice != value, PropertyName_Notice);
|
|
|
|
|
|
this.FirePropertyChanged(PropertyName_Notice);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-08-17 15:50:00 +02:00
|
|
|
|
public VarFieldListVM VarFields
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return _VarFields; }
|
|
|
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
if (AreDifferent(_VarFields, value))
|
|
|
|
|
|
{
|
|
|
|
|
|
_VarFields = value;
|
|
|
|
|
|
FirePropertyChanged(PropertyName_VarFields);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2016-06-27 01:45:38 +02:00
|
|
|
|
protected override void InitByDataContract(TeamDC pDataContract)
|
|
|
|
|
|
{
|
|
|
|
|
|
this._Member = new ObservableCollection<CompactEmployeeDC>();
|
2025-10-06 11:07:54 +02:00
|
|
|
|
this._OwnChatMember = new ObservableCollection<Person2TeamDC>();
|
2016-06-27 01:45:38 +02:00
|
|
|
|
if (!this.IsNew)
|
|
|
|
|
|
{
|
2025-10-06 11:07:54 +02:00
|
|
|
|
this._IsOwnChatTeam = pDataContract.IsOwnChatTeam;
|
2016-06-27 01:45:38 +02:00
|
|
|
|
this._Name = pDataContract.Name;
|
|
|
|
|
|
this._Notice = pDataContract.Notice;
|
|
|
|
|
|
this._Leader = pDataContract.Leader;
|
|
|
|
|
|
|
|
|
|
|
|
if (pDataContract.Member != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
this._Member.AddRange(pDataContract.Member.OrderBy(m => string.Format("{0},{1}", m.LastName, m.FirstName)));
|
|
|
|
|
|
}
|
2025-10-06 11:07:54 +02:00
|
|
|
|
if (pDataContract.OwnChatMember != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
this._OwnChatMember.AddRange(pDataContract.OwnChatMember.OrderBy(m => string.Format("{0},{1}", m.Person.LastName, m.Person.FirstName)));
|
|
|
|
|
|
}
|
2016-06-27 01:45:38 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2020-08-17 15:50:00 +02:00
|
|
|
|
_VarFields = new VarFieldListVM(pDataContract.TeamVarFields);
|
2016-06-27 01:45:38 +02:00
|
|
|
|
this._Member.CollectionChanged += (s, e) => this.StoreDirtyInformation(!pDataContract.Member.ContainsSameItemsAs(this._Member), PropertyName_Member);
|
2025-10-06 11:07:54 +02:00
|
|
|
|
this._OwnChatMember.CollectionChanged += (s, e) => this.StoreDirtyInformation(!pDataContract.OwnChatMember.ContainsSameItemsAs(this._OwnChatMember), nameof(OwnChatMember));
|
2016-06-27 01:45:38 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected override TeamDC MapToDataContract(TeamDC pDataContract, bool doCommit)
|
|
|
|
|
|
{
|
2025-10-06 11:07:54 +02:00
|
|
|
|
pDataContract.IsOwnChatTeam = this._IsOwnChatTeam;
|
2016-06-27 01:45:38 +02:00
|
|
|
|
pDataContract.Leader = this._Leader;
|
|
|
|
|
|
pDataContract.Name = this._Name;
|
|
|
|
|
|
pDataContract.Notice = this._Notice;
|
|
|
|
|
|
pDataContract.Member = this._Member.ToList();
|
2025-10-06 11:07:54 +02:00
|
|
|
|
pDataContract.OwnChatMember = this._OwnChatMember.ToList();
|
2020-08-17 15:50:00 +02:00
|
|
|
|
if (_VarFields != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
pDataContract.TeamVarFields = _VarFields.CopyToDCList(doCommit);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2016-06-27 01:45:38 +02:00
|
|
|
|
return pDataContract;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|