|
|
@ -5,27 +5,27 @@ using System.Linq;
|
|
|
|
using System.Text;
|
|
|
|
using System.Text;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
|
|
namespace model
|
|
|
|
namespace Model
|
|
|
|
{
|
|
|
|
{
|
|
|
|
public class Administrator
|
|
|
|
public class Administrator
|
|
|
|
{
|
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// define a DTO for an administrator
|
|
|
|
/// define an administrator
|
|
|
|
/// attributes :
|
|
|
|
/// attributes :
|
|
|
|
/// id : identifier in the database
|
|
|
|
/// id : identifier in the database
|
|
|
|
/// username : username for a player
|
|
|
|
/// username : username for a administrator
|
|
|
|
/// hashedPassword : hashed of the password of the player
|
|
|
|
/// hashedPassword : hash of the password of the administrator
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
private int id;
|
|
|
|
private int id;
|
|
|
|
private string? username;
|
|
|
|
private string? username;
|
|
|
|
private string hashedPassword;
|
|
|
|
private string? hashedPassword;
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// getters and setters for attributes
|
|
|
|
/// getters and setters for attributes
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
public int Id
|
|
|
|
public int Id
|
|
|
|
{
|
|
|
|
{
|
|
|
|
get => id;
|
|
|
|
get => id;
|
|
|
|
private set { id = value < 0 ? 0 : value; }
|
|
|
|
private set { id = value < -1 ? -1 : value; }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public string Username
|
|
|
|
public string Username
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -34,11 +34,17 @@ namespace model
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public string HashedPassword
|
|
|
|
public string HashedPassword
|
|
|
|
{
|
|
|
|
{
|
|
|
|
get => hashedPassword;
|
|
|
|
get => hashedPassword == null ? "" : hashedPassword;
|
|
|
|
set { hashedPassword = value; }
|
|
|
|
set { hashedPassword = value == "" ? null : value; }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Administrator(string username, string hashedPassword, int id)
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// constructor of an administrator
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
/// <param name="username">the username of the administrator</param>
|
|
|
|
|
|
|
|
/// <param name="hashedPassword">the hash of the password of the administrator</param>
|
|
|
|
|
|
|
|
/// <param name="id">the id in the database</param>
|
|
|
|
|
|
|
|
public Administrator(string username, string hashedPassword, int id = -1)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
this.Username = username;
|
|
|
|
this.Username = username;
|
|
|
|
this.HashedPassword = hashedPassword;
|
|
|
|
this.HashedPassword = hashedPassword;
|
|
|
|