diff --git a/MCTG/MCTGApp/MCTGApp.csproj b/MCTG/MCTGApp/ConsoleApp.csproj similarity index 100% rename from MCTG/MCTGApp/MCTGApp.csproj rename to MCTG/MCTGApp/ConsoleApp.csproj diff --git a/MCTG/MCTGApp/Program.cs b/MCTG/MCTGApp/Program.cs index 41aa1f4..deb6134 100644 --- a/MCTG/MCTGApp/Program.cs +++ b/MCTG/MCTGApp/Program.cs @@ -14,7 +14,7 @@ foreach (User user in users) { Console.WriteLine(user.Name); Console.WriteLine(user.Priorities[0].ToString()); - } catch (ArgumentNullException erreurNomVide) + } catch (ArgumentException erreurNomVide) { Console.WriteLine(erreurNomVide.Message); } diff --git a/MCTG/MCTGLib/MCTGLib.csproj b/MCTG/MCTGLib/Model.csproj similarity index 100% rename from MCTG/MCTGLib/MCTGLib.csproj rename to MCTG/MCTGLib/Model.csproj diff --git a/MCTG/MCTGLib/User.cs b/MCTG/MCTGLib/User.cs index bd4c9d8..4cda05a 100644 --- a/MCTG/MCTGLib/User.cs +++ b/MCTG/MCTGLib/User.cs @@ -4,6 +4,7 @@ using System.Collections; using System.Collections.ObjectModel; using System.Threading.Tasks; using System.Runtime.CompilerServices; +using System.Text.RegularExpressions; namespace MCTGLib { @@ -15,45 +16,39 @@ namespace MCTGLib { #region Private Attributes - private string name; - private string surname; - private string mail; - + private string name=""; + private string surname=""; + private string mail = ""; + private string picture = ""; + private string password = ""; + //private bool isAdmin; + private string defaultUserSavePath = ""; + private List priorities; #endregion #region Properties - private string picture; - /// - /// For now, we define the ProfilPict as a string which is "PhotoParDefaut" - /// when the value is null. - /// - public string ProfilPict - { - get => picture; - set => picture = value; - - } /// /// Property to get Name of users and a setter /// - /// Setter have Exception which is trigger when Name is null + /// Setter have Exception which is trigger when Name is null public string Name { get { return name; } - private set + private set { - if (string.IsNullOrWhiteSpace(value)) + if (string.IsNullOrWhiteSpace(value)) { - throw new ArgumentNullException("Il y a une erreur de Nom d'utilisateur!"); + throw new ArgumentException("Impossible d'avoir un champ Nom vide!"); } name = value; } } + /// /// Property to get Surname of users and a setter /// - /// Setter have Exception which is trigger when Surname is null + /// Setter have Exception which is trigger when Surname is null public string Surname { get { return surname; } @@ -61,15 +56,16 @@ namespace MCTGLib { if (string.IsNullOrWhiteSpace(value)) { - throw new ArgumentNullException("Il y a une erreur de Prénom d'utilisateur."); + throw new ArgumentException("Impossible d'avoir un champ Prénom vide!"); } surname = value; } } + /// /// Property to get mail of users and a setter /// - /// User's mail will serve to log the user. So there's no setter, just an init. User will enter one time his email at his + /// User's mail will serve to log the user. So there's no setter, just an init. User will enter one time his email at his /// account creation. public string Mail { @@ -78,14 +74,46 @@ namespace MCTGLib { if (string.IsNullOrWhiteSpace(value)) { - throw new ArgumentNullException("Il y a une erreur de Mail d'utilisateur."); + throw new ArgumentException("Impossible d'avoir un champ Email vide!"); } mail = value; } } + /// + /// For now, we define the ProfilPict as a string which is "PhotoParDefaut" + /// when the value is null. + /// + public string ProfilPict + { + get => picture; + set => picture = value; + + } - private List priorities; + /// + ///Password property + /// + public string Password + { + get => password; + private set + { + string modelPassword = @"[a-z]*[A-Z]+$" ; + if (!string.IsNullOrWhiteSpace(value)) + { + throw new ArgumentException("Le mot de passe ne doit pas etre vide "); + } + // if (Regex.IsMatch(value, modelPassword, RegexOptions. ) + } + + } + + /// + /// This is the list of priorities specific tu the user. This list is initiate + /// by default. User could change it at will. + /// + public List Priorities { get => priorities; @@ -109,6 +137,7 @@ namespace MCTGLib Name = name; Surname = surname; Mail = mail; + Password = password; priorities = new List { Priority.Gourmet, Priority.Economic,