move datamanagers in model, add author properties in recipe

pull/47/head
Alexandre AGOSTINHO 2 years ago
parent 86f6f73cea
commit 950a6f99bf

@ -5,7 +5,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace DataPersistence namespace Model
{ {
/// <summary> /// <summary>
/// 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. /// 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.

@ -4,7 +4,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace DataPersistence namespace Model
{ {
/// <summary> /// <summary>
/// Interface that define the methods of a data serializer. /// Interface that define the methods of a data serializer.

@ -31,6 +31,12 @@ namespace Model
[DataMember(Name = "reviews")] [DataMember(Name = "reviews")]
public List<Review> Reviews { get; private set; } public List<Review> Reviews { get; private set; }
/// <summary>
/// Author of the recipe.
/// </summary>
[DataMember(Name = "author")]
public User? Author { get; private set; }
/// <summary> /// <summary>
/// The Title of the recipe. <br/> /// The Title of the recipe. <br/>
/// Set to "No title." when the value passed is null, empty or contain white spaces. /// Set to "No title." when the value passed is null, empty or contain white spaces.
@ -69,7 +75,7 @@ namespace Model
/// <param _name="reviews">Thr list of reviews.</param> /// <param _name="reviews">Thr list of reviews.</param>
/// <param _name="ingredients">Thr list of ingredients.</param> /// <param _name="ingredients">Thr list of ingredients.</param>
/// <param _name="preparationSteps">The steps of the preparation of the meal</param> /// <param _name="preparationSteps">The steps of the preparation of the meal</param>
public Recipe(string title, int? id, public Recipe(string title, int? id, User? author,
List<Review> reviews, List<Ingredient> ingredients, List<Review> reviews, List<Ingredient> ingredients,
params PreparationStep[] preparationSteps) params PreparationStep[] preparationSteps)
{ {
@ -77,6 +83,7 @@ namespace Model
PreparationSteps = new List<PreparationStep>(preparationSteps); PreparationSteps = new List<PreparationStep>(preparationSteps);
Ingredients = ingredients; Ingredients = ingredients;
Reviews = reviews; Reviews = reviews;
Author = author;
if (id == null) if (id == null)
{ {
@ -93,7 +100,7 @@ namespace Model
/// </summary> /// </summary>
/// <param _name="title">The title of the recipe.</param> /// <param _name="title">The title of the recipe.</param>
public Recipe(string title) public Recipe(string title)
: this(title, null, new List<Review>(), new List<Ingredient>()) : this(title, null, null, new List<Review>(), new List<Ingredient>())
{ {
} }
@ -103,7 +110,7 @@ namespace Model
/// <param _name="title">The title of the recipe.</param> /// <param _name="title">The title of the recipe.</param>
/// <param _name="preparationSteps">The steps of the preparation of the meal.</param> /// <param _name="preparationSteps">The steps of the preparation of the meal.</param>
public Recipe(string title, params PreparationStep[] preparationSteps) public Recipe(string title, params PreparationStep[] preparationSteps)
: this(title, null, new List<Review>(), new List<Ingredient>(), preparationSteps) : this(title, null, null, new List<Review>(), new List<Ingredient>(), preparationSteps)
{ {
} }
@ -114,7 +121,7 @@ namespace Model
/// <param _name="id">The id of the recipe. If not given, get a new id.</param> /// <param _name="id">The id of the recipe. If not given, get a new id.</param>
/// <param _name="preparationSteps">The steps of the preparation of the meal.</param> /// <param _name="preparationSteps">The steps of the preparation of the meal.</param>
public Recipe(string title, int? id, params PreparationStep[] preparationSteps) public Recipe(string title, int? id, params PreparationStep[] preparationSteps)
: this(title, id, new List<Review>(), new List<Ingredient>(), preparationSteps) : this(title, id, null, new List<Review>(), new List<Ingredient>(), preparationSteps)
{ {
} }
@ -127,7 +134,7 @@ namespace Model
/// <param _name="preparationSteps">The steps of the preparation of the meal.</param> /// <param _name="preparationSteps">The steps of the preparation of the meal.</param>
public Recipe(string title, int? id, List<Ingredient> ingredients, public Recipe(string title, int? id, List<Ingredient> ingredients,
params PreparationStep[] preparationSteps) params PreparationStep[] preparationSteps)
: this(title, id, new List<Review>(), ingredients, preparationSteps) : this(title, id, null, new List<Review>(), ingredients, preparationSteps)
{ {
} }
#endregion #endregion
@ -203,8 +210,10 @@ namespace Model
{ {
sb.AppendLine(review.ToString()); sb.AppendLine(review.ToString());
} }
sb.AppendLine();
sb.AppendLine($"Posted by: {Author?.ToString()}");
return sb.ToString(); return sb.ToString();
} }
#endregion #endregion
} }
} }

Loading…
Cancel
Save