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.Threading.Tasks;
namespace DataPersistence
namespace Model
{
/// <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.

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

@ -31,6 +31,12 @@ namespace Model
[DataMember(Name = "reviews")]
public List<Review> Reviews { get; private set; }
/// <summary>
/// Author of the recipe.
/// </summary>
[DataMember(Name = "author")]
public User? Author { get; private set; }
/// <summary>
/// The Title of the recipe. <br/>
/// 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="ingredients">Thr list of ingredients.</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,
params PreparationStep[] preparationSteps)
{
@ -77,6 +83,7 @@ namespace Model
PreparationSteps = new List<PreparationStep>(preparationSteps);
Ingredients = ingredients;
Reviews = reviews;
Author = author;
if (id == null)
{
@ -93,7 +100,7 @@ namespace Model
/// </summary>
/// <param _name="title">The title of the recipe.</param>
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="preparationSteps">The steps of the preparation of the meal.</param>
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="preparationSteps">The steps of the preparation of the meal.</param>
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>
public Recipe(string title, int? id, List<Ingredient> ingredients,
params PreparationStep[] preparationSteps)
: this(title, id, new List<Review>(), ingredients, preparationSteps)
: this(title, id, null, new List<Review>(), 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
}
}
}

Loading…
Cancel
Save