using Models;

namespace ShoopNCook.Views;

public partial class IngredientEntry : ContentView
{
	public IngredientEntry()
	{
		InitializeComponent();
	}

	public Ingredient MakeValue()
	{
        float quantity;

        if (!float.TryParse(QuantityEntry.Text, out quantity))
        {
            quantity = 0;
            // TODO handle quantity text malformation by raising exception 
        }

        return new Ingredient(NameEntry.Text, quantity);
    }
}