You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
68 lines
1.6 KiB
68 lines
1.6 KiB
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
|
|
|
|
#region
|
|
/// <summary>
|
|
/// Property of the Ingredient's attribute name. It raises an ArgumentNullException to prevent a nullable field.
|
|
/// </summary>
|
|
public string Name
|
|
{
|
|
get => name;
|
|
set
|
|
{
|
|
if (value == null)
|
|
{
|
|
throw new ArgumentNullException("Impossible de ne pas avoir de nom pour l'ingrédient");
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Property of the Ingredient's attribute Quantity.
|
|
/// </summary>
|
|
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
|
|
|
|
}
|
|
}
|