From 38d83ff7776d569f469942ef3fe56d4ceccc8143 Mon Sep 17 00:00:00 2001 From: Roxane ROSSETTO Date: Thu, 4 May 2023 08:18:36 +0200 Subject: [PATCH 01/15] =?UTF-8?q?cr=C3=A9ation=20de=20la=20branche=20ingr?= =?UTF-8?q?=C3=A9dient=20et=20le=20fichier=20classe?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MCTG/Model/Ingredient.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 MCTG/Model/Ingredient.cs diff --git a/MCTG/Model/Ingredient.cs b/MCTG/Model/Ingredient.cs new file mode 100644 index 0000000..6efcd19 --- /dev/null +++ b/MCTG/Model/Ingredient.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Model +{ + internal class Ingredient + { + } +} From 8006b82d4d6e3ef342bb9839fd1ade0d3b286b10 Mon Sep 17 00:00:00 2001 From: Roxane ROSSETTO Date: Tue, 16 May 2023 17:00:34 +0200 Subject: [PATCH 02/15] conflict resolution --- MCTG/Model/Model.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MCTG/Model/Model.csproj b/MCTG/Model/Model.csproj index fd3452d..97854fe 100644 --- a/MCTG/Model/Model.csproj +++ b/MCTG/Model/Model.csproj @@ -1,4 +1,4 @@ - + net7.0 From 6376250b45180d4ffe184a630e093f0b379a96fe Mon Sep 17 00:00:00 2001 From: Roxane ROSSETTO Date: Wed, 17 May 2023 11:44:32 +0200 Subject: [PATCH 03/15] enum unit finished and quantity class finished, and I'm working on Ingredient --- MCTG/Model/Ingredient.cs | 34 ++++++++++++++++++++++++++++++++++ MCTG/Model/Quantity.cs | 12 ++++++++++++ MCTG/Model/Unit.cs | 11 +++++++++++ 3 files changed, 57 insertions(+) create mode 100644 MCTG/Model/Quantity.cs create mode 100644 MCTG/Model/Unit.cs diff --git a/MCTG/Model/Ingredient.cs b/MCTG/Model/Ingredient.cs index 6efcd19..cc3303c 100644 --- a/MCTG/Model/Ingredient.cs +++ b/MCTG/Model/Ingredient.cs @@ -8,5 +8,39 @@ namespace Model { internal class Ingredient { + #region Attributes + /// + /// Name of the ingredient + /// + private string name; + /// + /// get the quatity of ingredient + /// + private Quantity quantity; + + #endregion + + #region + public string Name + { + get => name; + set + { + if (value == null) + { + throw new ArgumentNullException("Impossible de ne pas avoir de nom pour l'ingrédient"); + } + } + } + + public Quantity QuantityP + { + get => quantity; + set => quantity = value; + } + + #endregion + + } } diff --git a/MCTG/Model/Quantity.cs b/MCTG/Model/Quantity.cs new file mode 100644 index 0000000..d59a3a6 --- /dev/null +++ b/MCTG/Model/Quantity.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Model +{ + internal class Quantity + { + } +} diff --git a/MCTG/Model/Unit.cs b/MCTG/Model/Unit.cs new file mode 100644 index 0000000..297c633 --- /dev/null +++ b/MCTG/Model/Unit.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Model +{ + public enum Unit + { Unit, kG, mG, G, L, cL, mL }; +} From e3d83292b8424c9691f956d9a4d6ed006468b8d8 Mon Sep 17 00:00:00 2001 From: Roxane ROSSETTO Date: Wed, 17 May 2023 11:45:28 +0200 Subject: [PATCH 04/15] I forgot to save Quantity... second push --- MCTG/Model/Quantity.cs | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/MCTG/Model/Quantity.cs b/MCTG/Model/Quantity.cs index d59a3a6..ccaf89d 100644 --- a/MCTG/Model/Quantity.cs +++ b/MCTG/Model/Quantity.cs @@ -6,7 +6,31 @@ using System.Threading.Tasks; namespace Model { - internal class Quantity + public class Quantity { + #region Attributes + /// + /// get the quatity of ingredient + /// + private int number; + /// + /// have the Unit enum of the quantity of ingredient + /// + private Unit unit; + + #endregion + + public int Number + { + get { return number; } + set + { + if (value <0 ) + { + throw new ArgumentException("Si la quantité est inférieur à 0, enlever l'ingrédient!"); + } + number = value; + } + } } } From 649ed6f72fc06d69d2323fed1004d387ee02797d Mon Sep 17 00:00:00 2001 From: Roxane Date: Fri, 19 May 2023 18:30:09 +0200 Subject: [PATCH 05/15] Enumeration of units, quantity class and ingredient class are finished. Unit test of the ingredient class are done. I'm going to test them in the stub --- MCTG/Model/Ingredient.cs | 39 +++++++++++++++------ MCTG/Model/Quantity.cs | 31 ++++++++++++++-- MCTG/Model/Recipe.cs | 2 +- MCTG/Model/Unit.cs | 6 +++- MCTG/Tests/Model_UnitTests/Ingredient_UT.cs | 18 ++++++++++ 5 files changed, 80 insertions(+), 16 deletions(-) create mode 100644 MCTG/Tests/Model_UnitTests/Ingredient_UT.cs diff --git a/MCTG/Model/Ingredient.cs b/MCTG/Model/Ingredient.cs index cc3303c..a63a2ec 100644 --- a/MCTG/Model/Ingredient.cs +++ b/MCTG/Model/Ingredient.cs @@ -9,38 +9,55 @@ namespace Model internal class Ingredient { #region Attributes - /// - /// Name of the ingredient - /// - private string name; - /// - /// get the quatity of ingredient - /// - private Quantity quantity; + + private string name = ""; + private Quantity quantity = new Quantity(1, Unit.unit) ; #endregion #region + /// + /// Property of the Ingredient's attribute name. It raises an ArgumentNullException to prevent a nullable field. + /// public string Name { get => name; - set + set { - if (value == null) + if (value == null) { throw new ArgumentNullException("Impossible de ne pas avoir de nom pour l'ingrédient"); } } } - public Quantity QuantityP + /// + /// Property of the Ingredient's attribute Quantity. + /// + public Quantity QuantityI { get => quantity; set => quantity = value; + } + + public bool Equals(Ingredient? other) + { + if (other == null) { return false; } + if (this == other) { return true; } + return Name.Equals(other.Name); + } #endregion + #region Constructor + + public Ingredient(string name, Quantity quantity) + { + Name = name; + QuantityI = quantity; + } + #endregion } } diff --git a/MCTG/Model/Quantity.cs b/MCTG/Model/Quantity.cs index ccaf89d..7378634 100644 --- a/MCTG/Model/Quantity.cs +++ b/MCTG/Model/Quantity.cs @@ -6,6 +6,10 @@ 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. + /// public class Quantity { #region Attributes @@ -17,20 +21,41 @@ namespace Model /// have the Unit enum of the quantity of ingredient /// private Unit unit; - - #endregion + #endregion + /// + /// Represents the quantity in digits. The null value raise an argumentException. + /// public int Number { get { return number; } set { - if (value <0 ) + if (value < 0) { throw new ArgumentException("Si la quantité est inférieur à 0, enlever l'ingrédient!"); } number = value; } } + public Unit UnitQ + { + get => unit; + set => unit = value; + } + + + #region Constructor + /// + /// Constructor of Quantity + /// + /// + /// + public Quantity(int number, Unit unit) + { + Number = number; + UnitQ = unit; + } + #endregion } } diff --git a/MCTG/Model/Recipe.cs b/MCTG/Model/Recipe.cs index b43440b..eefb84a 100644 --- a/MCTG/Model/Recipe.cs +++ b/MCTG/Model/Recipe.cs @@ -32,7 +32,7 @@ namespace Model { StringBuilder sb = new StringBuilder(); foreach (string str in Ingredients) sb.Append("\t- " + str + "\n"); - + return sb.ToString(); } diff --git a/MCTG/Model/Unit.cs b/MCTG/Model/Unit.cs index 297c633..5e7d38c 100644 --- a/MCTG/Model/Unit.cs +++ b/MCTG/Model/Unit.cs @@ -6,6 +6,10 @@ using System.Threading.Tasks; namespace Model { - public enum Unit + /// + /// Unit is an Enum that represents the units of quantities + /// + /// + public enum Unit { Unit, kG, mG, G, L, cL, mL }; } diff --git a/MCTG/Tests/Model_UnitTests/Ingredient_UT.cs b/MCTG/Tests/Model_UnitTests/Ingredient_UT.cs new file mode 100644 index 0000000..35a6e2c --- /dev/null +++ b/MCTG/Tests/Model_UnitTests/Ingredient_UT.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Model_UnitTests +{ + public class Ingredient_UT + { + public void TestConstructIngredient() + { + Quantity quantity = new Quantity(200, Unit.mL); + Ingredient patate = new Ingredient("Patate", quantity); + Assert.Equal("Patate", patate.Nom); + } + } +} From dc8214915acd115352a78a1dde800a02b6422e16 Mon Sep 17 00:00:00 2001 From: Roxane Date: Fri, 19 May 2023 19:17:34 +0200 Subject: [PATCH 06/15] Ingredient class finished and tested --- MCTG/ConsoleApp/Program.cs | 29 ++++------------------------- MCTG/ConsoleApp/Stub_Ingredient.cs | 20 ++++++++++++++++++++ MCTG/Model/Ingredient.cs | 2 +- MCTG/Model/Unit.cs | 2 +- 4 files changed, 26 insertions(+), 27 deletions(-) create mode 100644 MCTG/ConsoleApp/Stub_Ingredient.cs diff --git a/MCTG/ConsoleApp/Program.cs b/MCTG/ConsoleApp/Program.cs index c0760f0..818e4b9 100644 --- a/MCTG/ConsoleApp/Program.cs +++ b/MCTG/ConsoleApp/Program.cs @@ -1,32 +1,11 @@ using System; +using ConsoleApp; using Model; -namespace Program; +Stub_Ingredient stub = new Stub_Ingredient(); -public static class Program -{ - public static void Main() - { - Console.WriteLine("Helle World!"); +Ingredient ing = stub.testIngredient(); - Recipe recipe = new Recipe( - 1, - "Cookies aux pépites de chocolat", - new List(new string[]{ - "2 pommes", - "3L de vin", - "500g de farine" - }), - "Etape 1:\n" - + "\tCouper les pommes\n" - + "Etape 2:\n" - + "\tLes disposer sur le plat et mettre le vin dessus\n" - + "Etape 3:\n" - + "\tMettez toute la farine ensuite, puis 4h32 au four.\n" - + "\nDégustez c'est prêt !" - ); +Console.WriteLine(ing); - recipe.Display(); - } -} \ No newline at end of file diff --git a/MCTG/ConsoleApp/Stub_Ingredient.cs b/MCTG/ConsoleApp/Stub_Ingredient.cs new file mode 100644 index 0000000..6882276 --- /dev/null +++ b/MCTG/ConsoleApp/Stub_Ingredient.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Model; + +namespace ConsoleApp +{ + internal struct Stub_Ingredient + { + public Ingredient testIngredient() + { + Ingredient ingredient = new Ingredient("Patate", new Quantity(5, Unit.unit)); + return ingredient; + } + + + } +} diff --git a/MCTG/Model/Ingredient.cs b/MCTG/Model/Ingredient.cs index a63a2ec..46e5d36 100644 --- a/MCTG/Model/Ingredient.cs +++ b/MCTG/Model/Ingredient.cs @@ -6,7 +6,7 @@ using System.Threading.Tasks; namespace Model { - internal class Ingredient + public class Ingredient { #region Attributes diff --git a/MCTG/Model/Unit.cs b/MCTG/Model/Unit.cs index 5e7d38c..b745126 100644 --- a/MCTG/Model/Unit.cs +++ b/MCTG/Model/Unit.cs @@ -11,5 +11,5 @@ namespace Model /// /// public enum Unit - { Unit, kG, mG, G, L, cL, mL }; + { unit, kG, mG, G, L, cL, mL }; } From 6b424b0304b35fdae6fb0c5b7064c44cacdf156e Mon Sep 17 00:00:00 2001 From: Roxane Date: Fri, 19 May 2023 19:30:21 +0200 Subject: [PATCH 07/15] correction of tests after seeing drone alert --- MCTG/ConsoleApp/Stub_Ingredient.cs | 2 +- MCTG/Tests/Model_UnitTests/Ingredient_UT.cs | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/MCTG/ConsoleApp/Stub_Ingredient.cs b/MCTG/ConsoleApp/Stub_Ingredient.cs index 6882276..50b5ab2 100644 --- a/MCTG/ConsoleApp/Stub_Ingredient.cs +++ b/MCTG/ConsoleApp/Stub_Ingredient.cs @@ -11,7 +11,7 @@ namespace ConsoleApp { public Ingredient testIngredient() { - Ingredient ingredient = new Ingredient("Patate", new Quantity(5, Unit.unit)); + Ingredient ingredient = new("Patate", new Quantity(5, Unit.unit)); return ingredient; } diff --git a/MCTG/Tests/Model_UnitTests/Ingredient_UT.cs b/MCTG/Tests/Model_UnitTests/Ingredient_UT.cs index 35a6e2c..2f3ef79 100644 --- a/MCTG/Tests/Model_UnitTests/Ingredient_UT.cs +++ b/MCTG/Tests/Model_UnitTests/Ingredient_UT.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Model; namespace Model_UnitTests { @@ -12,7 +13,7 @@ namespace Model_UnitTests { Quantity quantity = new Quantity(200, Unit.mL); Ingredient patate = new Ingredient("Patate", quantity); - Assert.Equal("Patate", patate.Nom); + Assert.Equal("Patate", patate.Name); } } } From 7758ed44014d764b67cd24118d816840dcefdbf5 Mon Sep 17 00:00:00 2001 From: Roxane Date: Fri, 19 May 2023 19:40:58 +0200 Subject: [PATCH 08/15] test correct 1 --- MCTG/SAE-2.01.sln | 3 +++ MCTG/Tests/Model_UnitTests/Model_UnitTests.csproj | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/MCTG/SAE-2.01.sln b/MCTG/SAE-2.01.sln index cbadb1d..9e6d0a8 100644 --- a/MCTG/SAE-2.01.sln +++ b/MCTG/SAE-2.01.sln @@ -10,6 +10,9 @@ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Views", "Views\Views.csproj", "{508B5600-AFD0-4AE4-A3CF-5FA8BE3ECE75}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Model_UnitTests", "Tests\Model_UnitTests\Model_UnitTests.csproj", "{45AB746A-194B-4E43-81EB-83B06F35AA33}" + ProjectSection(ProjectDependencies) = postProject + {42FF86BD-92F9-4A32-A938-68515905378F} = {42FF86BD-92F9-4A32-A938-68515905378F} + EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{08B80CE8-A01D-4D86-8989-AF225D5DA48C}" EndProject diff --git a/MCTG/Tests/Model_UnitTests/Model_UnitTests.csproj b/MCTG/Tests/Model_UnitTests/Model_UnitTests.csproj index 423f4e0..424d218 100644 --- a/MCTG/Tests/Model_UnitTests/Model_UnitTests.csproj +++ b/MCTG/Tests/Model_UnitTests/Model_UnitTests.csproj @@ -23,4 +23,8 @@ + + + + From 6e5b6ca7a97563f85117005f96bd98a250bd08f9 Mon Sep 17 00:00:00 2001 From: Roxane ROSSETTO Date: Tue, 23 May 2023 15:09:04 +0200 Subject: [PATCH 09/15] implementation of datacontract on ingredient --- MCTG/Model/Ingredient.cs | 6 +++++- MCTG/Model/Quantity.cs | 8 ++++++++ MCTG/Model/Unit.cs | 2 ++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/MCTG/Model/Ingredient.cs b/MCTG/Model/Ingredient.cs index 46e5d36..79b38b7 100644 --- a/MCTG/Model/Ingredient.cs +++ b/MCTG/Model/Ingredient.cs @@ -1,16 +1,20 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Runtime.Serialization; using System.Text; using System.Threading.Tasks; namespace Model { + [DataContract(Name ="ingredient")] public class Ingredient { #region Attributes - + [DataMember(Name ="id")] private string name = ""; + + [DataMember(Name ="quantity")] private Quantity quantity = new Quantity(1, Unit.unit) ; #endregion diff --git a/MCTG/Model/Quantity.cs b/MCTG/Model/Quantity.cs index 7378634..af88cd8 100644 --- a/MCTG/Model/Quantity.cs +++ b/MCTG/Model/Quantity.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Runtime.Serialization; using System.Text; using System.Threading.Tasks; @@ -10,19 +11,24 @@ 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. /// + [DataContract(Name ="quantity")] public class Quantity { #region Attributes /// /// get the quatity of ingredient /// + [DataMember(Name ="digit")] private int number; /// /// have the Unit enum of the quantity of ingredient /// + [DataMember(Name ="unit")] private Unit unit; #endregion + + #region Properties /// /// Represents the quantity in digits. The null value raise an argumentException. /// @@ -44,6 +50,8 @@ namespace Model set => unit = value; } + #endregion + #region Constructor /// diff --git a/MCTG/Model/Unit.cs b/MCTG/Model/Unit.cs index b745126..8cf2b21 100644 --- a/MCTG/Model/Unit.cs +++ b/MCTG/Model/Unit.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Runtime.Serialization; using System.Text; using System.Threading.Tasks; @@ -10,6 +11,7 @@ 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 }; } From 0ca871a1db91be0f16a6a38bfcda814a3178b9b2 Mon Sep 17 00:00:00 2001 From: Alexandre Agostinho Date: Wed, 24 May 2023 11:48:55 +0200 Subject: [PATCH 10/15] fix sln conflict --- MCTG/SAE-2.01.sln | 65 ----------------------------------------------- 1 file changed, 65 deletions(-) diff --git a/MCTG/SAE-2.01.sln b/MCTG/SAE-2.01.sln index 25319c8..c73c36d 100644 --- a/MCTG/SAE-2.01.sln +++ b/MCTG/SAE-2.01.sln @@ -1,67 +1,3 @@ -<<<<<<< HEAD - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.5.33516.290 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConsoleApp", "ConsoleApp\ConsoleApp.csproj", "{666C2211-8EBB-4FC8-9484-CB93BC854153}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Model", "Model\Model.csproj", "{42FF86BD-92F9-4A32-A938-68515905378F}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Views", "Views\Views.csproj", "{508B5600-AFD0-4AE4-A3CF-5FA8BE3ECE75}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Model_UnitTests", "Tests\Model_UnitTests\Model_UnitTests.csproj", "{45AB746A-194B-4E43-81EB-83B06F35AA33}" - ProjectSection(ProjectDependencies) = postProject - {42FF86BD-92F9-4A32-A938-68515905378F} = {42FF86BD-92F9-4A32-A938-68515905378F} - EndProjectSection -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{08B80CE8-A01D-4D86-8989-AF225D5DA48C}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - CI|Any CPU = CI|Any CPU - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {666C2211-8EBB-4FC8-9484-CB93BC854153}.CI|Any CPU.ActiveCfg = Release|Any CPU - {666C2211-8EBB-4FC8-9484-CB93BC854153}.CI|Any CPU.Build.0 = Release|Any CPU - {666C2211-8EBB-4FC8-9484-CB93BC854153}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {666C2211-8EBB-4FC8-9484-CB93BC854153}.Debug|Any CPU.Build.0 = Debug|Any CPU - {666C2211-8EBB-4FC8-9484-CB93BC854153}.Release|Any CPU.ActiveCfg = Release|Any CPU - {666C2211-8EBB-4FC8-9484-CB93BC854153}.Release|Any CPU.Build.0 = Release|Any CPU - {42FF86BD-92F9-4A32-A938-68515905378F}.CI|Any CPU.ActiveCfg = Release|Any CPU - {42FF86BD-92F9-4A32-A938-68515905378F}.CI|Any CPU.Build.0 = Release|Any CPU - {42FF86BD-92F9-4A32-A938-68515905378F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {42FF86BD-92F9-4A32-A938-68515905378F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {42FF86BD-92F9-4A32-A938-68515905378F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {42FF86BD-92F9-4A32-A938-68515905378F}.Release|Any CPU.Build.0 = Release|Any CPU - {508B5600-AFD0-4AE4-A3CF-5FA8BE3ECE75}.CI|Any CPU.ActiveCfg = CI|Any CPU - {508B5600-AFD0-4AE4-A3CF-5FA8BE3ECE75}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {508B5600-AFD0-4AE4-A3CF-5FA8BE3ECE75}.Debug|Any CPU.Build.0 = Debug|Any CPU - {508B5600-AFD0-4AE4-A3CF-5FA8BE3ECE75}.Debug|Any CPU.Deploy.0 = Debug|Any CPU - {508B5600-AFD0-4AE4-A3CF-5FA8BE3ECE75}.Release|Any CPU.ActiveCfg = Release|Any CPU - {508B5600-AFD0-4AE4-A3CF-5FA8BE3ECE75}.Release|Any CPU.Build.0 = Release|Any CPU - {508B5600-AFD0-4AE4-A3CF-5FA8BE3ECE75}.Release|Any CPU.Deploy.0 = Release|Any CPU - {45AB746A-194B-4E43-81EB-83B06F35AA33}.CI|Any CPU.ActiveCfg = Release|Any CPU - {45AB746A-194B-4E43-81EB-83B06F35AA33}.CI|Any CPU.Build.0 = Release|Any CPU - {45AB746A-194B-4E43-81EB-83B06F35AA33}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {45AB746A-194B-4E43-81EB-83B06F35AA33}.Debug|Any CPU.Build.0 = Debug|Any CPU - {45AB746A-194B-4E43-81EB-83B06F35AA33}.Release|Any CPU.ActiveCfg = Release|Any CPU - {45AB746A-194B-4E43-81EB-83B06F35AA33}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(NestedProjects) = preSolution - {45AB746A-194B-4E43-81EB-83B06F35AA33} = {08B80CE8-A01D-4D86-8989-AF225D5DA48C} - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {ADEA5603-1EF6-4D43-9493-7D6D9DE7FA3F} - EndGlobalSection -EndGlobal -======= - Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.5.33516.290 @@ -117,4 +53,3 @@ Global SolutionGuid = {ADEA5603-1EF6-4D43-9493-7D6D9DE7FA3F} EndGlobalSection EndGlobal ->>>>>>> dev From 48b64facc2b543ba6723019b2548b54438bd89fd Mon Sep 17 00:00:00 2001 From: Alexandre Agostinho Date: Wed, 24 May 2023 11:50:38 +0200 Subject: [PATCH 11/15] fix sln conflict 2 --- MCTG/Tests/Model_UnitTests/Model_UnitTests.csproj | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/MCTG/Tests/Model_UnitTests/Model_UnitTests.csproj b/MCTG/Tests/Model_UnitTests/Model_UnitTests.csproj index 545b9be..aff436e 100644 --- a/MCTG/Tests/Model_UnitTests/Model_UnitTests.csproj +++ b/MCTG/Tests/Model_UnitTests/Model_UnitTests.csproj @@ -19,17 +19,9 @@ all -<<<<<<< HEAD - - - - - - -======= ->>>>>>> dev + From 91573ffdeab67d8dd59e78f69551c198a4f835ca Mon Sep 17 00:00:00 2001 From: Alexandre Agostinho Date: Wed, 24 May 2023 11:52:39 +0200 Subject: [PATCH 12/15] fix namespace ingredient --- MCTG/Tests/Model_UnitTests/Ingredient_UT.cs | 36 ++++++++++----------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/MCTG/Tests/Model_UnitTests/Ingredient_UT.cs b/MCTG/Tests/Model_UnitTests/Ingredient_UT.cs index c6164af..5849ec8 100644 --- a/MCTG/Tests/Model_UnitTests/Ingredient_UT.cs +++ b/MCTG/Tests/Model_UnitTests/Ingredient_UT.cs @@ -1,19 +1,19 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Model.Ingredient; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Model; -namespace Model_UnitTests -{ - public class Ingredient_UT - { - public void TestConstructIngredient() - { - Quantity quantity = new Quantity(200, Unit.mL); - Ingredient patate = new Ingredient("Patate", quantity); - Assert.Equal("Patate", patate.Name); - } - } -} +namespace Model_UnitTests +{ + public class Ingredient_UT + { + public void TestConstructIngredient() + { + Quantity quantity = new Quantity(200, Unit.mL); + Ingredient patate = new Ingredient("Patate", quantity); + Assert.Equal("Patate", patate.Name); + } + } +} From 86f6f73cead5256da7516679e0cf9f669ebb8b30 Mon Sep 17 00:00:00 2001 From: Alexandre Agostinho Date: Wed, 24 May 2023 13:27:57 +0200 Subject: [PATCH 13/15] fix ingredient --- MCTG/ConsoleApp/Program.cs | 4 +-- MCTG/DataPersistence/DataContractJSON.cs | 3 +- MCTG/DataPersistence/DataContractXML.cs | 3 +- .../{ => Recipes}/Ingredient/Ingredient.cs | 15 ++++---- .../{ => Recipes}/Ingredient/Quantity.cs | 12 +++---- MCTG/Model/{ => Recipes}/Ingredient/Unit.cs | 1 - MCTG/Model/Recipes/PreparationStep.cs | 4 +-- MCTG/Model/Recipes/Recipe.cs | 35 ++++++++++--------- MCTG/Model/Recipes/RecipeCollection.cs | 10 +++--- MCTG/Model/User/User.cs | 8 ++--- 10 files changed, 47 insertions(+), 48 deletions(-) rename MCTG/Model/{ => Recipes}/Ingredient/Ingredient.cs (74%) rename MCTG/Model/{ => Recipes}/Ingredient/Quantity.cs (78%) rename MCTG/Model/{ => Recipes}/Ingredient/Unit.cs (87%) 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; From 950a6f99bfde3f9bbd940eaaa5b2a17be1c77be8 Mon Sep 17 00:00:00 2001 From: Alexandre Agostinho Date: Wed, 24 May 2023 13:43:55 +0200 Subject: [PATCH 14/15] move datamanagers in model, add author properties in recipe --- .../Managers}/DataManager.cs | 2 +- .../Managers}/IDataManager.cs | 2 +- MCTG/Model/Recipes/Recipe.cs | 21 +++++++++++++------ 3 files changed, 17 insertions(+), 8 deletions(-) rename MCTG/{DataPersistence => Model/Managers}/DataManager.cs (99%) rename MCTG/{DataPersistence => Model/Managers}/IDataManager.cs (98%) diff --git a/MCTG/DataPersistence/DataManager.cs b/MCTG/Model/Managers/DataManager.cs similarity index 99% rename from MCTG/DataPersistence/DataManager.cs rename to MCTG/Model/Managers/DataManager.cs index a06d94d..9b5277c 100644 --- a/MCTG/DataPersistence/DataManager.cs +++ b/MCTG/Model/Managers/DataManager.cs @@ -5,7 +5,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace DataPersistence +namespace Model { /// /// Define the manager of the data. This is where all the data are put, and where we call the loading and the saving of them. diff --git a/MCTG/DataPersistence/IDataManager.cs b/MCTG/Model/Managers/IDataManager.cs similarity index 98% rename from MCTG/DataPersistence/IDataManager.cs rename to MCTG/Model/Managers/IDataManager.cs index 95209d8..c8a4ca6 100644 --- a/MCTG/DataPersistence/IDataManager.cs +++ b/MCTG/Model/Managers/IDataManager.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace DataPersistence +namespace Model { /// /// Interface that define the methods of a data serializer. diff --git a/MCTG/Model/Recipes/Recipe.cs b/MCTG/Model/Recipes/Recipe.cs index 84c168d..472f438 100644 --- a/MCTG/Model/Recipes/Recipe.cs +++ b/MCTG/Model/Recipes/Recipe.cs @@ -31,6 +31,12 @@ namespace Model [DataMember(Name = "reviews")] public List Reviews { get; private set; } + /// + /// Author of the recipe. + /// + [DataMember(Name = "author")] + public User? Author { get; private set; } + /// /// The Title of the recipe.
/// Set to "No title." when the value passed is null, empty or contain white spaces. @@ -69,7 +75,7 @@ namespace Model /// Thr list of reviews. /// Thr list of ingredients. /// The steps of the preparation of the meal - public Recipe(string title, int? id, + public Recipe(string title, int? id, User? author, List reviews, List ingredients, params PreparationStep[] preparationSteps) { @@ -77,6 +83,7 @@ namespace Model PreparationSteps = new List(preparationSteps); Ingredients = ingredients; Reviews = reviews; + Author = author; if (id == null) { @@ -93,7 +100,7 @@ namespace Model ///
/// The title of the recipe. public Recipe(string title) - : this(title, null, new List(), new List()) + : this(title, null, null, new List(), new List()) { } @@ -103,7 +110,7 @@ namespace Model /// 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) + : this(title, null, null, new List(), new List(), preparationSteps) { } @@ -114,7 +121,7 @@ namespace Model /// 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) + : this(title, id, null, new List(), new List(), preparationSteps) { } @@ -127,7 +134,7 @@ namespace Model /// 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) + : this(title, id, null, new List(), ingredients, preparationSteps) { } #endregion @@ -203,8 +210,10 @@ namespace Model { sb.AppendLine(review.ToString()); } + sb.AppendLine(); + sb.AppendLine($"Posted by: {Author?.ToString()}"); return sb.ToString(); } #endregion } -} \ No newline at end of file +} From 01fe143c7ff210308abb185a75ae5b01eaf2ecde Mon Sep 17 00:00:00 2001 From: Alexandre Agostinho Date: Wed, 24 May 2023 14:00:54 +0200 Subject: [PATCH 15/15] add some functions to simplify the access of data --- MCTG/ConsoleApp/Program.cs | 6 ++++-- MCTG/Model/Managers/DataManager.cs | 24 ++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/MCTG/ConsoleApp/Program.cs b/MCTG/ConsoleApp/Program.cs index 2e438a9..c200562 100644 --- a/MCTG/ConsoleApp/Program.cs +++ b/MCTG/ConsoleApp/Program.cs @@ -23,9 +23,11 @@ dataMgr.Serializer = new DataContractXML(); //dataMgr.Import("C:\\Users\\alex6\\Downloads\\recipe2.json"); PasswordManager passwordManager = new PasswordManager(); -RecipeCollection rc = new RecipeCollection("All recipes", dataMgr.Data[nameof(Recipe)].Cast().ToArray()); +//RecipeCollection rc = new RecipeCollection("All recipes", dataMgr.Data[nameof(Recipe)].Cast().ToArray()); +RecipeCollection rc = dataMgr.GetRecipes("All recipes"); +//RecipeCollection rc = new RecipeCollection("All recipes", dataMgr.GetFromData().ToArray()); -User user = dataMgr.Data[nameof(User)].Cast().Last(); +User user = dataMgr.GetUsers().Last(); //rc[0].AddReview(new Review(user, 1, "bonne recette !1")); //rc[0].AddReview(new Review(user, 1, "bonne recette !2")); diff --git a/MCTG/Model/Managers/DataManager.cs b/MCTG/Model/Managers/DataManager.cs index 9b5277c..d84f433 100644 --- a/MCTG/Model/Managers/DataManager.cs +++ b/MCTG/Model/Managers/DataManager.cs @@ -76,6 +76,30 @@ namespace Model public void Export(T obj, string pathToExport) where T : class => Serializer.Export(obj, pathToExport); + + /// + /// Get all the recipe from the data. + /// + /// The title to give for the Recipe Collection + /// A RecipeCollection that contain all the recipe in the data. + public RecipeCollection GetRecipes(string rcTitle = "default") + => new RecipeCollection(rcTitle, Data[nameof(Recipe)].Cast().ToArray()); + + /// + /// Get all the Users from the data. + /// + /// A list of all Users. + public List GetUsers() + => new List(Data[nameof(User)].Cast()); + + /// + /// Get a list of an item in the data. + /// + /// The type of the item + /// The list of all the item found in the data. + public ICollection GetFromData() where T : class + => new List(Data[typeof(T).Name].Cast()); + #endregion } }