|
|
|
@ -1,3 +1,4 @@
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Collections;
|
|
|
|
@ -7,6 +8,7 @@ using System.Runtime.CompilerServices;
|
|
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Runtime.Serialization;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
|
|
|
|
|
namespace Model
|
|
|
|
|
{
|
|
|
|
@ -15,7 +17,7 @@ namespace Model
|
|
|
|
|
/// This user can login with an Id and a password
|
|
|
|
|
/// </summary>
|
|
|
|
|
[DataContract(Name = "user")]
|
|
|
|
|
public class User : IEquatable<User>
|
|
|
|
|
public class User : IEquatable<User> , INotifyPropertyChanged
|
|
|
|
|
{
|
|
|
|
|
#region Private Attributes
|
|
|
|
|
|
|
|
|
@ -25,6 +27,8 @@ namespace Model
|
|
|
|
|
[DataMember] private string picture = "";
|
|
|
|
|
[DataMember] private int password ;
|
|
|
|
|
[DataMember] private List<Priority> priorities;
|
|
|
|
|
|
|
|
|
|
public event PropertyChangedEventHandler? PropertyChanged;
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Properties
|
|
|
|
@ -36,13 +40,11 @@ namespace Model
|
|
|
|
|
public string Name
|
|
|
|
|
{
|
|
|
|
|
get { return name; }
|
|
|
|
|
private set
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrWhiteSpace(value))
|
|
|
|
|
{
|
|
|
|
|
throw new ArgumentException("Impossible d'avoir un champ Nom vide!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
name = value;
|
|
|
|
|
OnPropertyChanged();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -53,13 +55,11 @@ namespace Model
|
|
|
|
|
public string Surname
|
|
|
|
|
{
|
|
|
|
|
get { return surname; }
|
|
|
|
|
private set
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrWhiteSpace(value))
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
throw new ArgumentException("Impossible d'avoir un champ Prénom vide!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
surname = value;
|
|
|
|
|
OnPropertyChanged();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -129,6 +129,21 @@ namespace Model
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected void OnPropertyChanged ([CallerMemberName] string? propertyName = null)
|
|
|
|
|
{
|
|
|
|
|
if (PropertyChanged != null)
|
|
|
|
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string ToString()
|
|
|
|
|
{
|
|
|
|
|
return $"{Name} {Surname}";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IPasswordManager psswMgr { get; private set; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Constructors
|
|
|
|
@ -136,15 +151,18 @@ namespace Model
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Construtors of user.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param _name="name">The _name of the user</param>
|
|
|
|
|
/// <param _name="surname">The surname of the user</param>
|
|
|
|
|
/// <param _name="mail">The user needs an email to login. </param>
|
|
|
|
|
public User(string name, string surname, string mail, int password)
|
|
|
|
|
/// <param name="name">The name of the user</param>
|
|
|
|
|
/// <param name="surname">The surname of the user</param>
|
|
|
|
|
/// <param name="mail">The user needs an email to login.</param>
|
|
|
|
|
/// <param name="password">The password of the new user.</param>
|
|
|
|
|
/// <param name="passwordManager">The password manager to manage the user password.</param>
|
|
|
|
|
public User(string name, string surname, string mail, string password, IPasswordManager passwordManager )
|
|
|
|
|
{
|
|
|
|
|
Name = name;
|
|
|
|
|
Surname = surname;
|
|
|
|
|
Mail = mail;
|
|
|
|
|
Password = password;
|
|
|
|
|
psswMgr = passwordManager;
|
|
|
|
|
Password = psswMgr.HashPassword(password);
|
|
|
|
|
priorities = new List<Priority> {
|
|
|
|
|
Priority.Gourmet,
|
|
|
|
|
Priority.Economic,
|
|
|
|
@ -155,8 +173,40 @@ namespace Model
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <inheritdoc cref="User.User"/>
|
|
|
|
|
/// </summary>
|
|
|
|
|
public User(string name, string surname, string mail, string password)
|
|
|
|
|
: this(name, surname,mail, password, new PasswordManager())
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <inheritdoc cref="User.User"/>
|
|
|
|
|
/// </summary>
|
|
|
|
|
public User()
|
|
|
|
|
: this("John", "Doe", "truc@gmail.com", "mdp")
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <inheritdoc cref="User.User"/>
|
|
|
|
|
/// </summary>
|
|
|
|
|
public User (User user)
|
|
|
|
|
{
|
|
|
|
|
Name = user.Name;
|
|
|
|
|
Surname = user.Surname;
|
|
|
|
|
Mail = user.Mail;
|
|
|
|
|
psswMgr = user.psswMgr;
|
|
|
|
|
Password = user.Password;
|
|
|
|
|
priorities = user.Priorities;
|
|
|
|
|
ProfilPict = user.ProfilPict;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|