From 474c03887456041fd375275064f7218b2c2d98e7 Mon Sep 17 00:00:00 2001 From: Roxane ROSSETTO Date: Tue, 2 May 2023 15:39:33 +0200 Subject: [PATCH] Modification of the property Mail. Now, we want this property to never be empty or null because it will serve for login --- MCTG/MCTGLib/User.cs | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/MCTG/MCTGLib/User.cs b/MCTG/MCTGLib/User.cs index f4a2f65..cc43db6 100644 --- a/MCTG/MCTGLib/User.cs +++ b/MCTG/MCTGLib/User.cs @@ -37,7 +37,7 @@ namespace MCTGLib { throw new ArgumentNullException("Erreur pour la photo d'utilisateur!"); } - + } } /// @@ -67,15 +67,27 @@ namespace MCTGLib { if (string.IsNullOrWhiteSpace(value)) { - throw new ArgumentNullException("Il y a une erreur de Prénom d'utilisateur"); + throw new ArgumentNullException("Il y a une erreur de Prénom d'utilisateur."); } 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 + /// account creation. public string Mail { get { return mail; } - private set { mail = value; } + init + { + if (string.IsNullOrWhiteSpace(value)) + { + throw new ArgumentNullException("Il y a une erreur de Mail d'utilisateur."); + } + mail = value; + } } @@ -95,6 +107,9 @@ namespace MCTGLib /// /// Construtors of user. /// + /// The name of the user + /// The surname of the user + /// The user needs an email to login. public User(string name, string surname, string mail) { Name = name;