private void btnAdicionar_Click(object sender, EventArgs e) { if (txtQuantidade.Text != string.Empty) { LinhaIngrediente novaLinha = new LinhaIngrediente(); novaLinha.Quantidade = int.Parse(txtQuantidade.Text); novaLinha.Unidade = new Unidade((int)cboUnidade.SelectedValue); novaLinha.Ingrediente = new Ingrediente((int)cboIngrediente.SelectedValue); novaReceita.LinhasIngrediente.Add((novaLinha)); } }
protected void btnAdicionar_Click(object sender, EventArgs e) { if (txtQuantidade.Text != string.Empty) { Receita novaReceita = (Receita)Session["Receita"]; LinhaIngrediente novalinha = new LinhaIngrediente(); novalinha.IdReceita = novaReceita.Id; novalinha.Quantidade = double.Parse(txtQuantidade.Text); novalinha.Unidade = new Unidade(int.Parse(ddUnidade.SelectedValue)); novalinha.Ingrediente = new Ingrediente(int.Parse((ddIngrediente.SelectedValue))); novaReceita.LinhasIngrediente.Add((novalinha)); lblListaIngredientes.Text += novalinha.Quantidade + " " + novalinha.Unidade.Nome + " de " + novalinha.Ingrediente.Nome + "<br/>"; } }