You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.9 KiB

using System.ComponentModel;
using System.Runtime.CompilerServices;
namespace YOUserbase {
public class User : INotifyPropertyChanged {
int id;
string firstname;
string lastname;
DateTime birthDate;
string details;
Group workingGroup;
bool isFullTime;
bool isExternal;
bool isRemote;
int nbProjects;
public int Id { get => id; set => ChangeValue(ref id, value); }
public string Firstname { get => firstname; set => ChangeValue(ref firstname, value); }
public string Lastname { get => lastname; set => ChangeValue(ref lastname, value); }
public DateTime BirthDate { get => birthDate; set => ChangeValue(ref birthDate, value); }
public string Details { get => details; set => ChangeValue(ref details, value); }
public Group WorkingGroup { get => workingGroup; set => ChangeValue(ref workingGroup, value); }
public bool IsFullTime { get => isFullTime; set => ChangeValue(ref isFullTime, value); }
public bool IsExternal { get => isExternal; set => ChangeValue(ref isExternal, value); }
public bool IsRemote { get => isRemote; set => ChangeValue(ref isRemote, value); }
public int NbProjects { get => nbProjects; set => ChangeValue(ref nbProjects, value); }
private static int index = 0;
public User() {
Id = ++index;
}
public User(int id) {
Id = id;
}
// Wrpper to change vaulue and notify if it changed
private void ChangeValue<T>(ref T field, T value, [CallerMemberName] string propertyName = "") {
if(!value.Equals(field)) {
field = value;
if(PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
public event PropertyChangedEventHandler PropertyChanged;
}
}