diff --git a/MCTG/ConsoleApp/Program.cs b/MCTG/ConsoleApp/Program.cs index 7b0d711..2e438a9 100644 --- a/MCTG/ConsoleApp/Program.cs +++ b/MCTG/ConsoleApp/Program.cs @@ -11,8 +11,8 @@ Console.WriteLine("Hello, World!\n\n"); // TESTS: -//DataManager dataMgr = new DataManager(new Stubs()); -DataManager dataMgr = new DataManager(new DataContractXML()); +DataManager dataMgr = new DataManager(new Stubs()); +//DataManager dataMgr = new DataManager(new DataContractXML()); //DataManager dataMgr = new DataManager(new DataContractJSON()); dataMgr.Serializer = new DataContractXML(); diff --git a/MCTG/DataPersistence/DataContractJSON.cs b/MCTG/DataPersistence/DataContractJSON.cs index 2e5d2ee..13879b7 100644 --- a/MCTG/DataPersistence/DataContractJSON.cs +++ b/MCTG/DataPersistence/DataContractJSON.cs @@ -40,8 +40,7 @@ namespace DataPersistence typeof(Review), typeof(User), typeof(Ingredient), - typeof(Quantity), - typeof(Unit) + typeof(Quantity) } }; else diff --git a/MCTG/DataPersistence/DataContractXML.cs b/MCTG/DataPersistence/DataContractXML.cs index ebd8f8f..3cd4f58 100644 --- a/MCTG/DataPersistence/DataContractXML.cs +++ b/MCTG/DataPersistence/DataContractXML.cs @@ -48,8 +48,7 @@ namespace DataPersistence typeof(Review), typeof(User), typeof(Ingredient), - typeof(Quantity), - typeof(Unit) + typeof(Quantity) }, PreserveObjectReferences = true }; diff --git a/MCTG/Model/Ingredient/Ingredient.cs b/MCTG/Model/Recipes/Ingredient/Ingredient.cs similarity index 74% rename from MCTG/Model/Ingredient/Ingredient.cs rename to MCTG/Model/Recipes/Ingredient/Ingredient.cs index 908c19b..c8452d8 100644 --- a/MCTG/Model/Ingredient/Ingredient.cs +++ b/MCTG/Model/Recipes/Ingredient/Ingredient.cs @@ -12,26 +12,27 @@ namespace Model { #region Attributes [DataMember(Name = "id")] - private string name = ""; + private string _name = ""; [DataMember(Name = "quantity")] - private Quantity quantity = new Quantity(1, Unit.unit); + private Quantity _quantity = new Quantity(1, Unit.unit); #endregion #region Properties /// - /// Property of the Ingredient's attribute name. It raises an ArgumentNullException to prevent a nullable field. + /// Property of the Ingredient's attribute _name. It raises an ArgumentNullException to prevent a nullable field. /// public string Name { - get => name; + get => _name; set { - if (value == null) + if (string.IsNullOrEmpty(value)) { throw new ArgumentNullException("Impossible de ne pas avoir de nom pour l'ingrédient"); } + _name = value; } } @@ -40,8 +41,8 @@ namespace Model /// public Quantity QuantityI { - get => quantity; - set => quantity = value; + get => _quantity; + set => _quantity = value; } diff --git a/MCTG/Model/Ingredient/Quantity.cs b/MCTG/Model/Recipes/Ingredient/Quantity.cs similarity index 78% rename from MCTG/Model/Ingredient/Quantity.cs rename to MCTG/Model/Recipes/Ingredient/Quantity.cs index f731ad0..35ab858 100644 --- a/MCTG/Model/Ingredient/Quantity.cs +++ b/MCTG/Model/Recipes/Ingredient/Quantity.cs @@ -8,8 +8,8 @@ using System.Threading.Tasks; namespace Model { /// - /// Quantity is a class which is associate to Ingedients. It represents the quantity of every ingredient with an enum - /// to indicate the unit of the quantity. + /// Quantity is a class which is associate to Ingedients. It represents the _quantity of every ingredient with an enum + /// to indicate the unit of the _quantity. /// [DataContract(Name = "quantity")] public class Quantity @@ -21,7 +21,7 @@ namespace Model [DataMember(Name = "digit")] private int number; /// - /// have the Unit enum of the quantity of ingredient + /// have the Unit enum of the _quantity of ingredient /// [DataMember(Name = "unit")] private Unit unit; @@ -30,7 +30,7 @@ namespace Model #region Properties /// - /// Represents the quantity in digits. The null value raise an argumentException. + /// Represents the _quantity in digits. The null value raise an argumentException. /// public int Number { @@ -56,8 +56,8 @@ namespace Model /// /// Constructor of Quantity /// - /// - /// + /// + /// public Quantity(int number, Unit unit) { Number = number; diff --git a/MCTG/Model/Ingredient/Unit.cs b/MCTG/Model/Recipes/Ingredient/Unit.cs similarity index 87% rename from MCTG/Model/Ingredient/Unit.cs rename to MCTG/Model/Recipes/Ingredient/Unit.cs index ab5c3e3..9d450e1 100644 --- a/MCTG/Model/Ingredient/Unit.cs +++ b/MCTG/Model/Recipes/Ingredient/Unit.cs @@ -11,7 +11,6 @@ namespace Model /// Unit is an Enum that represents the units of quantities /// /// - [DataContract(Name = "enumUnit")] public enum Unit { unit, kG, mG, G, L, cL, mL }; } diff --git a/MCTG/Model/Recipes/PreparationStep.cs b/MCTG/Model/Recipes/PreparationStep.cs index f9d5aa3..32cb2d9 100644 --- a/MCTG/Model/Recipes/PreparationStep.cs +++ b/MCTG/Model/Recipes/PreparationStep.cs @@ -46,8 +46,8 @@ namespace Model /// /// Construct a new step of preparation. /// - /// The number of the order in preparation - /// The description of the task + /// The number of the order in preparation + /// The description of the task public PreparationStep(int order, string description = "") { Order = order; diff --git a/MCTG/Model/Recipes/Recipe.cs b/MCTG/Model/Recipes/Recipe.cs index 56f0254..84c168d 100644 --- a/MCTG/Model/Recipes/Recipe.cs +++ b/MCTG/Model/Recipes/Recipe.cs @@ -50,6 +50,7 @@ namespace Model /// /// The list of ingredients. /// + [DataMember(Name = "ingredient")] public List Ingredients { get; set; } /// @@ -63,11 +64,11 @@ namespace Model /// /// Construct a new recipe. /// - /// The title of the recipe - /// The id of the recipe. If not given, get a new id. - /// Thr list of reviews. - /// Thr list of ingredients. - /// The steps of the preparation of the meal + /// The title of the recipe + /// The id of the recipe. If not given, get a new id. + /// Thr list of reviews. + /// Thr list of ingredients. + /// The steps of the preparation of the meal public Recipe(string title, int? id, List reviews, List ingredients, params PreparationStep[] preparationSteps) @@ -90,7 +91,7 @@ namespace Model /// /// /// - /// The title of the recipe. + /// The title of the recipe. public Recipe(string title) : this(title, null, new List(), new List()) { @@ -99,8 +100,8 @@ namespace Model /// /// /// - /// The title of the recipe. - /// The steps of the preparation of the meal. + /// The title of the recipe. + /// The steps of the preparation of the meal. public Recipe(string title, params PreparationStep[] preparationSteps) : this(title, null, new List(), new List(), preparationSteps) { @@ -109,9 +110,9 @@ namespace Model /// /// /// - /// The title of the recipe. - /// The id of the recipe. If not given, get a new id. - /// The steps of the preparation of the meal. + /// The title of the recipe. + /// The id of the recipe. If not given, get a new id. + /// The steps of the preparation of the meal. public Recipe(string title, int? id, params PreparationStep[] preparationSteps) : this(title, id, new List(), new List(), preparationSteps) { @@ -120,10 +121,10 @@ namespace Model /// /// /// - /// The title of the recipe. - /// The id of the recipe. If not given, get a new id. - /// Thr list of ingredients. - /// The steps of the preparation of the meal. + /// The title of the recipe. + /// The id of the recipe. If not given, get a new id. + /// Thr list of ingredients. + /// The steps of the preparation of the meal. public Recipe(string title, int? id, List ingredients, params PreparationStep[] preparationSteps) : this(title, id, new List(), ingredients, preparationSteps) @@ -135,7 +136,7 @@ namespace Model /// /// Add a review for the recipe. /// - /// The new review to add. + /// The new review to add. public void AddReview(Review review) => Reviews.Add(review); @@ -162,7 +163,7 @@ namespace Model StringBuilder sb = new StringBuilder(); foreach (Ingredient ingredient in Ingredients) { - sb.Append("\t- " + ingredient + "\n"); + sb.Append("\t- " + ingredient.ToString() + "\n"); } return sb.ToString(); diff --git a/MCTG/Model/Recipes/RecipeCollection.cs b/MCTG/Model/Recipes/RecipeCollection.cs index a1d8393..ac7d17a 100644 --- a/MCTG/Model/Recipes/RecipeCollection.cs +++ b/MCTG/Model/Recipes/RecipeCollection.cs @@ -38,8 +38,8 @@ namespace Model /// /// Construct a new collection of _recipes. /// - /// A short description of what this list will contain - /// Recipes to add in this new collection + /// A short description of what this list will contain + /// Recipes to add in this new collection public RecipeCollection(string description, params Recipe[] recipes) : base(recipes) { @@ -51,7 +51,7 @@ namespace Model /// /// Find a recipe in this list by giving the id. /// - /// The id of the list we are looking for + /// The id of the list we are looking for /// The recipe of the id given /// public Recipe? GetRecipeById(int id) @@ -62,9 +62,9 @@ namespace Model } /// - /// Utility to find a recipe by his name. + /// Utility to find a recipe by his _name. /// - /// The string for the search + /// The string for the search /// A collection of Recipe where their Title contain the string. public RecipeCollection ResearchByName(string str) { diff --git a/MCTG/Model/User/User.cs b/MCTG/Model/User/User.cs index 9b9503e..f335472 100644 --- a/MCTG/Model/User/User.cs +++ b/MCTG/Model/User/User.cs @@ -11,7 +11,7 @@ using System.Runtime.Serialization; namespace Model { /// - /// A user is an entity with a name, a surname, mail, profilePict and a list of priority. + /// A user is an entity with a _name, a surname, mail, profilePict and a list of priority. /// This user can login with an Id and a password /// [DataContract(Name = "user")] @@ -137,9 +137,9 @@ namespace Model /// /// Construtors of user. /// - /// The name of the user - /// The surname of the user - /// The user needs an email to login. + /// 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, int password) { Name = name;