Tried to initiate the user's password and put some constraint to it
continuous-integration/drone/push Build is failing Details

pull/35/head^2
Roxane ROSSETTO 2 years ago
parent df9577d690
commit e9c2c4ff7b

@ -14,7 +14,7 @@ foreach (User user in users)
{ {
Console.WriteLine(user.Name); Console.WriteLine(user.Name);
Console.WriteLine(user.Priorities[0].ToString()); Console.WriteLine(user.Priorities[0].ToString());
} catch (ArgumentNullException erreurNomVide) } catch (ArgumentException erreurNomVide)
{ {
Console.WriteLine(erreurNomVide.Message); Console.WriteLine(erreurNomVide.Message);
} }

@ -4,6 +4,7 @@ using System.Collections;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Text.RegularExpressions;
namespace MCTGLib namespace MCTGLib
{ {
@ -15,45 +16,39 @@ namespace MCTGLib
{ {
#region Private Attributes #region Private Attributes
private string name; private string name="";
private string surname; private string surname="";
private string mail; private string mail = "";
private string picture = "";
private string password = "";
//private bool isAdmin;
private string defaultUserSavePath = "";
private List<Priority> priorities;
#endregion #endregion
#region Properties #region Properties
private string picture;
/// <summary>
/// For now, we define the ProfilPict as a string which is "PhotoParDefaut"
/// when the value is null.
/// </summary>
public string ProfilPict
{
get => picture;
set => picture = value;
}
/// <summary> /// <summary>
/// Property to get Name of users and a setter /// Property to get Name of users and a setter
/// </summary> /// </summary>
/// <exception cref="ArgumentNullException" >Setter have Exception which is trigger when Name is null</exception> /// <exception cref="ArgumentException" >Setter have Exception which is trigger when Name is null</exception>
public string Name public string Name
{ {
get { return 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; name = value;
} }
} }
/// <summary> /// <summary>
/// Property to get Surname of users and a setter /// Property to get Surname of users and a setter
/// </summary> /// </summary>
/// <exception cref="ArgumentNullException" >Setter have Exception which is trigger when Surname is null</exception> /// <exception cref="ArgumentException" >Setter have Exception which is trigger when Surname is null</exception>
public string Surname public string Surname
{ {
get { return surname; } get { return surname; }
@ -61,15 +56,16 @@ namespace MCTGLib
{ {
if (string.IsNullOrWhiteSpace(value)) 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; surname = value;
} }
} }
/// <summary> /// <summary>
/// Property to get mail of users and a setter /// Property to get mail of users and a setter
/// </summary> /// </summary>
/// <exception cref="ArgumentNullException" >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 /// <exception cref="ArgumentException" >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.</exception> /// account creation.</exception>
public string Mail public string Mail
{ {
@ -78,14 +74,46 @@ namespace MCTGLib
{ {
if (string.IsNullOrWhiteSpace(value)) 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; mail = value;
} }
} }
/// <summary>
/// For now, we define the ProfilPict as a string which is "PhotoParDefaut"
/// when the value is null.
/// </summary>
public string ProfilPict
{
get => picture;
set => picture = value;
}
private List<Priority> priorities; ///<summary>
///Password property
/// </summary>
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. )
}
}
/// <summary>
/// This is the list of priorities specific tu the user. This list is initiate
/// by default. User could change it at will.
/// </summary>
public List<Priority> Priorities public List<Priority> Priorities
{ {
get => priorities; get => priorities;
@ -109,6 +137,7 @@ namespace MCTGLib
Name = name; Name = name;
Surname = surname; Surname = surname;
Mail = mail; Mail = mail;
Password = password;
priorities = new List<Priority> { priorities = new List<Priority> {
Priority.Gourmet, Priority.Gourmet,
Priority.Economic, Priority.Economic,

Loading…
Cancel
Save