diff --git a/MCTG/ConsoleApp/Program.cs b/MCTG/ConsoleApp/Program.cs index ead495b..7d068d6 100644 --- a/MCTG/ConsoleApp/Program.cs +++ b/MCTG/ConsoleApp/Program.cs @@ -25,7 +25,7 @@ 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()); User user = dataMgr.Data[nameof(User)].Cast().Last(); diff --git a/MCTG/DataPersistence/Stubs.cs b/MCTG/DataPersistence/Stubs.cs index 2b32fec..177672d 100644 --- a/MCTG/DataPersistence/Stubs.cs +++ b/MCTG/DataPersistence/Stubs.cs @@ -23,14 +23,18 @@ namespace DataPersistence new List(new[] { new Recipe( - title: "Cookies classiques", id: null, + title: "Cookies classiques", + picture : "room_service_icon.png", + id: null, preparationSteps: new[] { new PreparationStep(1, "Faire cuire."), new PreparationStep(2, "Manger.") }), new Recipe( - title: "Cookies au chocolat", id: null, + title: "Cookies au chocolat", + picture : "", + id: null, preparationSteps: new[] { new PreparationStep(1, "Moulinez la pâte."), @@ -38,34 +42,39 @@ namespace DataPersistence new PreparationStep(3, "Sortir du four et mettre dans un plat.") }), new Recipe( - title: "Gateau nature", id: null, + title: "Gateau nature", + picture : "dotnet_bot.svg", + id: null, preparationSteps: new[] { new PreparationStep(1, "Achetez les ingrédients."), new PreparationStep(2, "Préparez le matériel. Ustensiles et tout."), new PreparationStep(3, "Pleurez.") }), - new Recipe( - title: "Gateau au pommes", id: null, + new Recipe( + title: "Gateau nature", + picture : "dotnet_bot.svg", + id: null, preparationSteps: new[] { - new PreparationStep(1, "Achetez les légumes."), - new PreparationStep(2, "Préparez le plat. Ustensiles et préchauffez le four."), - new PreparationStep(3, "Coupez les pommes en morceaux et disposez-les sur le plat."), - new PreparationStep(4, "Mettez enfin le plat au four, puis une fois cuit, dégustez !") + new PreparationStep(1, "Achetez les ingrédients."), + new PreparationStep(2, "Préparez le matériel. Ustensiles et tout."), + new PreparationStep(3, "Pleurez.") }), - new Recipe( - title: "Gateau au chocolat", id: null, + new Recipe( + title: "Gateau nature", + picture : "dotnet_bot.svg", + id: null, preparationSteps: new[] { - new PreparationStep(1, "Ajouter les oeufs."), - new PreparationStep(2, "Ajouter la farine."), - new PreparationStep(3, "Ajouter 100g de chocolat fondu."), - new PreparationStep(4, "Mélanger le tout."), - new PreparationStep(5, "Faire cuire 45h au four traditionnel.") + new PreparationStep(1, "Achetez les ingrédients."), + new PreparationStep(2, "Préparez le matériel. Ustensiles et tout."), + new PreparationStep(3, "Pleurez.") }), new Recipe( - title: "Dinde au jambon", id: null, + title: "Dinde au jambon", + picture : "", + id: null, preparationSteps: new[] { new PreparationStep(1, "Faire une cuisson bien sec de la dinde à la poêle"), @@ -75,16 +84,15 @@ namespace DataPersistence new PreparationStep(5, "Présentez sur un plat la dinde et le jambon : Miam !") }), new Recipe( - title: "Poulet au curry", id: null, + title: "Gateau nature", + picture : "dotnet_bot.svg", + id: null, preparationSteps: new[] { - new PreparationStep(1, "Trouvez des épices de curry."), - new PreparationStep(2, "Trouvez maintenant du poulet."), - new PreparationStep(3, "Coupez la tête du poulet et posez-la dans un plat."), - new PreparationStep(4, "Parsemez d'épices curry la tête de la poule."), - new PreparationStep(5, "Mettre le tout au four traditionnel 30min."), - new PreparationStep(6, "Dégustez en famille !") - }) + new PreparationStep(1, "Achetez les ingrédients."), + new PreparationStep(2, "Préparez le matériel. Ustensiles et tout."), + new PreparationStep(3, "Pleurez.") + }), }) #endregion }, diff --git a/MCTG/Model/Recipes/Recipe.cs b/MCTG/Model/Recipes/Recipe.cs index fe81d0a..63b74ab 100644 --- a/MCTG/Model/Recipes/Recipe.cs +++ b/MCTG/Model/Recipes/Recipe.cs @@ -16,6 +16,9 @@ namespace Model #region Attributes [DataMember(Name = "title")] private string _title = ""; + + [DataMember(Name = "image")] + private string _image = ""; #endregion #region Properties @@ -47,6 +50,21 @@ namespace Model } } + /// + /// The image of the recipe.
+ /// Set to "room_service_icon.png" when the value passed is null, empty or contain white space. + ///
+ public string Image + { + get => _image; + set + { + if (!string.IsNullOrWhiteSpace(value)) + _image = "room_service_icon.png"; + _image = value; + } + } + /// /// The steps of the preparation. See: . /// @@ -61,11 +79,12 @@ 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 - public Recipe(string title, int? id, + public Recipe(string title, string picture, int? id, List reviews, params PreparationStep[] preparationSteps) { Title = title; + Image = picture; PreparationSteps = new List(preparationSteps); Reviews = reviews; @@ -83,8 +102,8 @@ namespace Model /// /// /// The title of the recipe. - public Recipe(string title) - : this(title, null, new List()) + public Recipe(string title, string picture) + : this(title, picture, null, new List()) { } @@ -94,7 +113,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(), preparationSteps) + : this(title, picture : null, null, new List(), preparationSteps) { } @@ -104,8 +123,8 @@ 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. - public Recipe(string title, int? id, params PreparationStep[] preparationSteps) - : this(title, id, new List(), preparationSteps) + public Recipe(string title, string picture, int? id, params PreparationStep[] preparationSteps) + : this(title, picture, id, new List(), preparationSteps) { } #endregion diff --git a/MCTG/Views/AddRecipe.xaml b/MCTG/Views/AddRecipe.xaml index 05d250d..3f2460b 100644 --- a/MCTG/Views/AddRecipe.xaml +++ b/MCTG/Views/AddRecipe.xaml @@ -4,10 +4,10 @@ x:Class="Views.AddRecipe" Title="AddRecipe" xmlns:local="clr-namespace:Views"> - - +