add documentation on new code
continuous-integration/drone/push Build is passing Details

pull/55/head
Alexandre AGOSTINHO 2 years ago
parent ef78348599
commit 0f4071f465

@ -24,7 +24,7 @@ namespace ConsoleApp.Menu
string surname = _selectList[2].Item.Input;
string passwd = _selectList[3].Item.Input;
User user = masterMgr.User.CreateUser(name, surname, mail, passwd, null);
User user = masterMgr.User.CreateUser(mail, passwd, name, surname);
masterMgr.User.AddUserToData(user);
return null;

@ -41,7 +41,8 @@ namespace Managers
return true;
}
public User CreateUser(string? name, string? surname, string mail, string password, string? profilePict)
public User CreateUser(string mail, string password,
string? name = null, string? surname = null, string? profilePict = null)
{
if (name is null) name = $"user{GetRandomInt()}";
if (surname is null) surname = "";

@ -7,6 +7,9 @@ using System.Threading.Tasks;
namespace Model
{
/// <summary>
/// Define how to manage data.
/// </summary>
public interface IDataManager
{
/// <summary>

@ -6,10 +6,24 @@ using System.Threading.Tasks;
namespace Model
{
/// <summary>
/// Define how to manage passwords.
/// </summary>
public interface IPasswordManager
{
/// <summary>
/// Hash a plain text password.
/// </summary>
/// <param name="password">The plain password to hash.</param>
/// <returns>The hashed password.</returns>
public string HashPassword(string password);
public bool VerifyPassword(string hashedPassword,string password);
/// <summary>
/// Verify a plain text password with a hashed one.
/// </summary>
/// <param name="hashedPassword">The hashed password.</param>
/// <param name="password">The plain text password.</param>
/// <returns>True is the password is correct, false otherwise.</returns>
public bool VerifyPassword(string hashedPassword,string password);
}
}

@ -6,16 +6,62 @@ using System.Threading.Tasks;
namespace Model
{
/// <summary>
/// Define how to manage recipes.
/// </summary>
public interface IRecipeManager
{
/// <summary>
/// Get or set the currently selected recipe.
/// </summary>
Recipe? CurrentSelected { get; set; }
/// <summary>
/// Get all the recipe in the data.
/// </summary>
/// <returns>The RecipeCollection containing the recipes stored in the data.</returns>
RecipeCollection GetAllRecipes();
/// <summary>
/// Get the recipe corresponding to the id.
/// </summary>
/// <param name="id">The id of the recipe we want.</param>
/// <returns>The recipe corresponding to the id.</returns>
Recipe GetRecipeFromId(int id);
/// <summary>
/// Search in data the recipes containing this part of title.
/// </summary>
/// <param name="title">Search string.</param>
/// <returns>The RecipeCollection of recipes corresponding to the search.</returns>
RecipeCollection SearchRecipeByTitle(string title);
/// <summary>
/// Get all the recipes created by the author.
/// </summary>
/// <param name="authorMail">The author's mail.</param>
/// <returns>The RecipeCollection of the recipe created by the author.</returns>
RecipeCollection GetRecipeByAuthor(string authorMail);
/// <summary>
/// Get an ordored list of the recipes sorted by the priority list.
/// </summary>
/// <param name="priority">The priority list.</param>
/// <returns>The RecipeCollection ordored by the priority list.</returns>
RecipeCollection GetRecipesByPriorityOrder(IEnumerable<Priority> priority);
/// <summary>
/// Add a recipe to the data.
/// </summary>
/// <param name="recipe">The recipe to add.</param>
/// <returns>Weither the adding succed or not.</returns>
bool AddRecipeToData(Recipe recipe);
/// <summary>
/// Modify the <see cref="CurrentSelected"/> recipe with a new one in the data.
/// </summary>
/// <param name="newRecipe">The new recipe</param>
/// <returns>Weither the modification succed or not.</returns>
bool ModifyCurrentSelected(Recipe newRecipe);
}
}

@ -6,14 +6,52 @@ using System.Threading.Tasks;
namespace Model
{
/// <summary>
/// Define how to manage an user.
/// </summary>
public interface IUserManager
{
/// <summary>
/// Get the current connected user. Null if no user is connected.
/// </summary>
User? CurrentConnected { get; }
/// <summary>
/// Get the password manager used to hash passords.
/// </summary>
IPasswordManager PasswordManager { get; }
/// <summary>
/// Get a collection of all users in the data.
/// </summary>
/// <returns>A collection of all user.</returns>
ICollection<User> GetAllUsers();
/// <summary>
/// Get an user by his email.
/// </summary>
/// <param name="mail">The user's mail.</param>
/// <returns>The user corresponding to the mail.</returns>
User GetUserFromMail(string mail);
User CreateUser(string? name, string? surname, string mail, string password, string? profilePict);
/// <summary>
/// Create a new user. The mail and the password are required. Other can be null.
/// <br/>This function use the password manager to hash the plain text password.
/// </summary>
/// <param name="mail">The user's mail address.</param>
/// <param name="password">The user's plain text password.</param>
/// <param name="name">The user's name.</param>
/// <param name="surname">The user's surname.</param>
/// <param name="profilePict">The user's profile picture.</param>
/// <returns>A new user.</returns>
User CreateUser(string mail, string password,
string? name = null, string? surname = null, string? profilePict = null);
/// <summary>
///
/// </summary>
/// <param name="user"></param>
/// <returns></returns>
bool AddUserToData(User user);
bool ModifyCurrentConnected(User newUser);
bool LogIn(string mail, string password);

Loading…
Cancel
Save