diff --git a/MCTG/DataPersistence/DataContractXML.cs b/MCTG/DataPersistence/DataContractXML.cs
index 3bd78f7..910d26d 100644
--- a/MCTG/DataPersistence/DataContractXML.cs
+++ b/MCTG/DataPersistence/DataContractXML.cs
@@ -49,7 +49,7 @@ namespace DataPersistence
typeof(User),
typeof(Ingredient),
typeof(Quantity),
- typeof(PasswordManager)
+ typeof(PasswordSHA256)
},
PreserveObjectReferences = true
};
diff --git a/MCTG/Model/Managers/MasterManager.cs b/MCTG/Model/Managers/MasterManager.cs
index d077da4..6bad13f 100644
--- a/MCTG/Model/Managers/MasterManager.cs
+++ b/MCTG/Model/Managers/MasterManager.cs
@@ -9,14 +9,38 @@ using System.Threading.Tasks;
namespace Model.Managers
{
+ ///
+ /// The Main manager of the model.
+ ///
public class MasterManager
{
+ #region Attributes & Properties
+ ///
+ /// The currently connected user. 'null' if no user is connected.
+ ///
public User? CurrentConnectedUser { get; private set; }
+
+ ///
+ /// The collection of all recipes loaded.
+ ///
public RecipeCollection Recipes { get; private set; }
+
+ ///
+ /// The collection of all users loaded.
+ ///
public List Users { get; private set; }
+ ///
+ /// The data manager for load, save, export and import data.
+ ///
public DataManager DataMgr { get; private set; }
+ #endregion
+ #region Constructors
+ ///
+ /// Constructor of the MasterManager.
+ ///
+ /// The serializer for the data.
public MasterManager(IDataManager dataManager)
{
DataMgr = new DataManager(dataManager);
@@ -24,7 +48,16 @@ namespace Model.Managers
Recipes = DataMgr.GetRecipes("all recipes");
Users = DataMgr.GetUsers();
}
+ #endregion
+ #region Methods
+ ///
+ /// Log in an user. Test if the log in information are correct then connect the user.
+ ///
+ /// The user's mail
+ /// The user's password.
+ /// True if the user was correctly connected, false if there is something wrong.
+ ///
public bool Login(string mail, string password)
{
if (Users is null || Users.Count == 0)
@@ -45,6 +78,10 @@ namespace Model.Managers
return true;
}
+ ///
+ /// Log out an user.
+ ///
+ /// True if the user is correctly diconnected, false otherwise.
public bool Logout()
{
if (CurrentConnectedUser is null)
@@ -54,6 +91,11 @@ namespace Model.Managers
return true;
}
+ ///
+ /// Register an user.
+ ///
+ /// The new user to add in the database.
+ /// False if there is a problem with the registerement, true otherwise.
public bool Register(User newuser)
{
try
@@ -71,14 +113,23 @@ namespace Model.Managers
return true;
}
+ ///
+ /// Add a recipe to the database.
+ ///
+ /// The recipe to add.
public void AddRecipe(Recipe recipe)
{
DataMgr.Data[nameof(Recipe)].Add(recipe);
Recipes = DataMgr.GetRecipes();
}
+ ///
+ /// Get the current connected user's personal recipes.
+ ///
+ /// The current connected user's personal recipes.
public RecipeCollection GetCurrentUserRecipes()
=> new RecipeCollection("User recipes",
DataMgr.GetRecipes().FindAll(r => r.AuthorMail == CurrentConnectedUser?.Mail).ToArray());
}
+ #endregion
}
diff --git a/MCTG/Model/Recipes/Review.cs b/MCTG/Model/Recipes/Review.cs
index 88b54c7..f55d6e7 100644
--- a/MCTG/Model/Recipes/Review.cs
+++ b/MCTG/Model/Recipes/Review.cs
@@ -10,21 +10,34 @@ using System.Xml.Linq;
namespace Model
{
+ ///
+ /// Define a Review of a recipe.
+ ///
[DataContract(Name = "review")]
public class Review : IEquatable
{
+ #region Attributes & Properties
[DataMember(Name = "stars")]
private int _stars;
[DataMember(Name = "content")]
private string _content = "";
+ ///
+ /// The Id of the review.
+ ///
[DataMember(Name = "id")]
public int Id { get; init; }
+ ///
+ /// The mail of the author of the review.
+ ///
[DataMember(Name = "authorMail")]
public string AuthorMail { get; private set; }
+ ///
+ /// The number of stars the review give.
+ ///
public int Stars
{
get => _stars;
@@ -35,6 +48,9 @@ namespace Model
}
}
+ ///
+ /// The comment in the review.
+ ///
public string Content
{
get => _content;
@@ -44,7 +60,16 @@ namespace Model
else _content = value;
}
}
+ #endregion
+ #region Constructors
+ ///
+ /// Constructor of a review.
+ ///
+ /// The review's author's mail.
+ /// The id of the review.
+ /// The mark to give for the recipe.
+ /// A comment about the recipe.
public Review(string authorMail, int? id, int stars, string content)
{
if (id == null)
@@ -61,16 +86,24 @@ namespace Model
Content = content;
}
+ ///
+ ///
+ ///
public Review(string authorMail, int stars, string content)
: this(authorMail, null, stars, content)
{
}
+ ///
+ ///
+ ///
public Review(int stars, string content)
: this("admin@mctg.fr", null, stars, content)
{
}
+ #endregion
+ #region Methods
public override string ToString()
{
return $"{AuthorMail}: [ {Stars} stars ]\n{Content}";
@@ -95,5 +128,6 @@ namespace Model
{
return Id.GetHashCode();
}
+ #endregion
}
}
diff --git a/MCTG/Model/User/PasswordManager.cs b/MCTG/Model/User/PasswordSHA256.cs
similarity index 94%
rename from MCTG/Model/User/PasswordManager.cs
rename to MCTG/Model/User/PasswordSHA256.cs
index 2aad1a2..e418de1 100644
--- a/MCTG/Model/User/PasswordManager.cs
+++ b/MCTG/Model/User/PasswordSHA256.cs
@@ -9,7 +9,7 @@ using System.Threading.Tasks;
namespace Model
{
[DataContract(Name = "passmgr")]
- public class PasswordManager : IPasswordManager
+ public class PasswordSHA256 : IPasswordManager
{
public string HashPassword(string password)
{
diff --git a/MCTG/Model/User/User.cs b/MCTG/Model/User/User.cs
index 57e13e6..1085d0e 100644
--- a/MCTG/Model/User/User.cs
+++ b/MCTG/Model/User/User.cs
@@ -1,12 +1,5 @@
-using System;
-using System.Collections.Generic;
-using System.Collections;
-using System.Collections.ObjectModel;
-using System.Threading.Tasks;
using System.Runtime.CompilerServices;
-using System.Text.RegularExpressions;
-using System.Text;
using System.Runtime.Serialization;
using System.ComponentModel;
@@ -178,7 +171,7 @@ namespace Model
///
///
public User(string name, string surname, string mail, string password)
- : this(name, surname,mail, password, new PasswordManager())
+ : this(name, surname,mail, password, new PasswordSHA256())
{
}
@@ -210,4 +203,3 @@ namespace Model
#endregion
}
}
-
diff --git a/MCTG/Tests/Model_UnitTests/test_unit_user.cs b/MCTG/Tests/Model_UnitTests/test_unit_user.cs
index 02cbcdb..45e4107 100644
--- a/MCTG/Tests/Model_UnitTests/test_unit_user.cs
+++ b/MCTG/Tests/Model_UnitTests/test_unit_user.cs
@@ -12,7 +12,7 @@ namespace Model_UnitTests
[Fact]
public void TestConstructUser()
{
- PasswordManager passwordManager = new PasswordManager();
+ PasswordSHA256 passwordManager = new PasswordSHA256();
User user = new User("Bob", "Dylan", "bd@gmail.com", "bobby");
Assert.Equal("Bob", user.Name);
Assert.Equal("Dylan", user.Surname);