private async void btnUpdate_Click(object sender, EventArgs e) { if (ValidateChildren()) { _ingredient.Name = txtName.Text; IngredientsUpsertRequest request = new IngredientsUpsertRequest { Description = _ingredient.Description, Id = _ingredient.Id, Name = _ingredient.Name, Status = _ingredient.Status, UnitID = _ingredient.UnitID }; try { _ingredient = await _service.Update <Model.Ingredients>(_ingredient.Id, request); MessageBox.Show("Success"); Close(); } catch { MessageBox.Show("Error"); } } }
private async void btnAdd_Click(object sender, EventArgs e) { if (numMeasure.Value == 0) { MessageBox.Show("Not able to add 0 measure number of ingredient!"); } else { Model.Ingredients ingredients = (Model.Ingredients)dgvIngredients.SelectedRows[0].DataBoundItem; var model = await _ingredients.GetById <Model.Ingredients>(ingredients.Id); if (GetExistedInModel(model.Id)) { SetQuantityFoExisting(model.Id); } else { ProductIngredientAdd tmp = new ProductIngredientAdd { ProductId = _product.Id, IngredientId = model.Id, Measure = (int)numMeasure.Value, Name = model.Name }; _ingredientAdd.Add(tmp); } dgvIngredients.AutoGenerateColumns = false; dgvIngredientsProducts.DataSource = null; dgvIngredients.DataSource = null; dgvIngredientsProducts.DataSource = _ingredientAdd; await FilterProducts(); } }
public frmIngredientEdit(Model.Ingredients ingredients) { InitializeComponent(); _ingredient = ingredients; }