예제 #1
0
        private void btnUpdateFood_Click(object sender, EventArgs e)
        {
            bool   result  = false;
            string name    = txtFoodName.Text.Trim();
            int    idCate  = (cbFoodCategory.SelectedItem as CategoryDTO).Id;
            float  price   = (float)nmFoodPrice.Value;
            int    idFood  = Convert.ToInt32(txtFoodID.Text.Trim());
            bool   existed = FoodDAO.Instance.IsExisedtFood(name);

            if (txtFoodName.Text.Equals(""))
            {
                MessageBox.Show("Empty input.");
                return;
            }

            if (MessageBox.Show(string.Format("Update this FoodID: {0}?", idFood), "Notification!!!", MessageBoxButtons.OKCancel) == DialogResult.OK)
            {
                result = FoodDAO.Instance.UpdateFood(idFood, name, idCate, price);
                if (result)
                {
                    MessageBox.Show("Update Successfully!");
                    LoadListFood();
                    UpdateFood.Invoke();
                }
                else
                {
                    MessageBox.Show("Update failed!");
                }
            }
        }
예제 #2
0
        public IActionResult Update(UpdateFood model)
        {
            if (ModelState.IsValid)
            {
                var result = new UpdateFoodResult();
                result = Helper.ApiHelper <UpdateFoodResult> .HttpPostAsync("api/Food/Update", "POST", model);

                if (result.FoodId > 0)
                {
                    return(RedirectToAction("index"));
                }
                ModelState.AddModelError("", result.Message);
                return(View(model));
            }
            return(View(model));
        }
예제 #3
0
 public IActionResult Update(int id, [FromBody] UpdateFood foodParam)
 {
     _foodService.updateFood(id, foodParam.name, foodParam.CategoryId, foodParam.price);
     return(Ok());
 }