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.
ShopNCook/Views/Components/IngredientEntry.xaml.cs

28 lines
731 B

using Models;
namespace ShoopNCook.Views;
// Classe représentant une entrée d'ingrédient
public partial class IngredientEntry : ContentView
{
public IngredientEntry()
{
InitializeComponent();
}
// Renvoie une nouvelle instance de Ingredient à partir des informations entrées par l'utilisateur
public Ingredient MakeValue()
{
float quantity;
// Tente de convertir la quantité en float, sinon, attribue une valeur par défaut de 0
if (!float.TryParse(QuantityEntry.Text, out quantity))
{
quantity = 0;
// TODO handle quantity text malformation by raising exception
}
return new Ingredient(NameEntry.Text, quantity);
}
}