fix ingredient

pull/47/head
Alexandre AGOSTINHO 2 years ago
parent 91573ffdea
commit 86f6f73cea

@ -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();

@ -40,8 +40,7 @@ namespace DataPersistence
typeof(Review),
typeof(User),
typeof(Ingredient),
typeof(Quantity),
typeof(Unit)
typeof(Quantity)
}
};
else

@ -48,8 +48,7 @@ namespace DataPersistence
typeof(Review),
typeof(User),
typeof(Ingredient),
typeof(Quantity),
typeof(Unit)
typeof(Quantity)
},
PreserveObjectReferences = true
};

@ -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
/// <summary>
/// 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.
/// </summary>
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
/// </summary>
public Quantity QuantityI
{
get => quantity;
set => quantity = value;
get => _quantity;
set => _quantity = value;
}

@ -8,8 +8,8 @@ using System.Threading.Tasks;
namespace Model
{
/// <summary>
/// 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.
/// </summary>
[DataContract(Name = "quantity")]
public class Quantity
@ -21,7 +21,7 @@ namespace Model
[DataMember(Name = "digit")]
private int number;
/// <summary>
/// have the Unit enum of the quantity of ingredient
/// have the Unit enum of the _quantity of ingredient
/// </summary>
[DataMember(Name = "unit")]
private Unit unit;
@ -30,7 +30,7 @@ namespace Model
#region Properties
/// <summary>
/// Represents the quantity in digits. The null value raise an argumentException.
/// Represents the _quantity in digits. The null value raise an argumentException.
/// </summary>
public int Number
{
@ -56,8 +56,8 @@ namespace Model
/// <summary>
/// Constructor of Quantity
/// </summary>
/// <param name="number"></param>
/// <param name="unit"></param>
/// <param _name="number"></param>
/// <param _name="unit"></param>
public Quantity(int number, Unit unit)
{
Number = number;

@ -11,7 +11,6 @@ namespace Model
/// Unit is an Enum that represents the units of quantities
/// <list type="Unit, kG, mG, G, L, cL, mL"/>
/// </summary>
[DataContract(Name = "enumUnit")]
public enum Unit
{ unit, kG, mG, G, L, cL, mL };
}

@ -46,8 +46,8 @@ namespace Model
/// <summary>
/// Construct a new step of preparation.
/// </summary>
/// <param name="order">The number of the order in preparation</param>
/// <param name="description">The description of the task</param>
/// <param _name="order">The number of the order in preparation</param>
/// <param _name="description">The description of the task</param>
public PreparationStep(int order, string description = "")
{
Order = order;

@ -50,6 +50,7 @@ namespace Model
/// <summary>
/// The list of ingredients.
/// </summary>
[DataMember(Name = "ingredient")]
public List<Ingredient> Ingredients { get; set; }
/// <summary>
@ -63,11 +64,11 @@ namespace Model
/// <summary>
/// Construct a new recipe.
/// </summary>
/// <param name="title">The title of the recipe</param>
/// <param name="id">The id of the recipe. If not given, get a new id.</param>
/// <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>
/// <param _name="title">The title of the recipe</param>
/// <param _name="id">The id of the recipe. If not given, get a new id.</param>
/// <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,
List<Review> reviews, List<Ingredient> ingredients,
params PreparationStep[] preparationSteps)
@ -90,7 +91,7 @@ namespace Model
/// <summary>
/// <inheritdoc cref="Recipe.Recipe(string, int?, List{Review}, PreparationStep[])"/>
/// </summary>
/// <param name="title">The title of the recipe.</param>
/// <param _name="title">The title of the recipe.</param>
public Recipe(string title)
: this(title, null, new List<Review>(), new List<Ingredient>())
{
@ -99,8 +100,8 @@ namespace Model
/// <summary>
/// <inheritdoc cref="Recipe.Recipe(string, int?, List{Review}, PreparationStep[])"/>
/// </summary>
/// <param name="title">The title of the recipe.</param>
/// <param name="preparationSteps">The steps of the preparation of the meal.</param>
/// <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)
{
@ -109,9 +110,9 @@ namespace Model
/// <summary>
/// <inheritdoc cref="Recipe.Recipe(string, int?, List{Review}, PreparationStep[])"/>
/// </summary>
/// <param name="title">The title of the recipe.</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="title">The title of the recipe.</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>
public Recipe(string title, int? id, params PreparationStep[] preparationSteps)
: this(title, id, new List<Review>(), new List<Ingredient>(), preparationSteps)
{
@ -120,10 +121,10 @@ namespace Model
/// <summary>
/// <inheritdoc cref="Recipe.Recipe(string, int?, List{Review}, PreparationStep[])"/>
/// </summary>
/// <param name="title">The title of the recipe.</param>
/// <param name="id">The id of the recipe. If not given, get a new id.</param>
/// <param name="ingredients">Thr list of ingredients.</param>
/// <param name="preparationSteps">The steps of the preparation of the meal.</param>
/// <param _name="title">The title of the recipe.</param>
/// <param _name="id">The id of the recipe. If not given, get a new id.</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, List<Ingredient> ingredients,
params PreparationStep[] preparationSteps)
: this(title, id, new List<Review>(), ingredients, preparationSteps)
@ -135,7 +136,7 @@ namespace Model
/// <summary>
/// Add a review for the recipe.
/// </summary>
/// <param name="review">The new review to add.</param>
/// <param _name="review">The new review to add.</param>
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();

@ -38,8 +38,8 @@ namespace Model
/// <summary>
/// Construct a new collection of _recipes.
/// </summary>
/// <param name="description">A short description of what this list will contain</param>
/// <param name="recipes">Recipes to add in this new collection</param>
/// <param _name="description">A short description of what this list will contain</param>
/// <param _name="recipes">Recipes to add in this new collection</param>
public RecipeCollection(string description, params Recipe[] recipes)
: base(recipes)
{
@ -51,7 +51,7 @@ namespace Model
/// <summary>
/// Find a recipe in this list by giving the id.
/// </summary>
/// <param name="id">The id of the list we are looking for</param>
/// <param _name="id">The id of the list we are looking for</param>
/// <returns>The recipe of the id given</returns>
/// <exception cref="ArgumentException"/>
public Recipe? GetRecipeById(int id)
@ -62,9 +62,9 @@ namespace Model
}
/// <summary>
/// Utility to find a recipe by his name.
/// Utility to find a recipe by his _name.
/// </summary>
/// <param name="str">The string for the search</param>
/// <param _name="str">The string for the search</param>
/// <returns>A collection of Recipe where their Title contain the string.</returns>
public RecipeCollection ResearchByName(string str)
{

@ -11,7 +11,7 @@ using System.Runtime.Serialization;
namespace Model
{
/// <summary>
/// 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
/// </summary>
[DataContract(Name = "user")]
@ -137,9 +137,9 @@ namespace Model
/// <summary>
/// Construtors of user.
/// </summary>
/// <param name="name">The name of the user</param>
/// <param name="surname">The surname of the user</param>
/// <param name="mail">The user needs an email to login. </param>
/// <param _name="name">The _name of the user</param>
/// <param _name="surname">The surname of the user</param>
/// <param _name="mail">The user needs an email to login. </param>
public User(string name, string surname, string mail, int password)
{
Name = name;

Loading…
Cancel
Save