Ejemplo n.º 1
0
        public ActionResult Edit(string id)
        {
            var dao = new FoodHandle();

            lsF = new FoodHandle().GetListFood();
            var food = dao.GetFood(id, lsF);

            SetViewBag(Int32.Parse(food.idCategory));
            return(View(food));
        }
Ejemplo n.º 2
0
        public ActionResult Delete(int id)
        {
            bool result = new FoodHandle().DeleteFood(id.ToString());

            if (result)
            {
                SetAlert("Xóa món thành công", "success");
                return(Redirect("/Food/DSFood"));;
            }
            else
            {
                ModelState.AddModelError("", "Xóa món thất bại");
            }
            return(Redirect("/Food/DSFood"));;
        }
Ejemplo n.º 3
0
 public ActionResult Edit(Food model)
 {
     if (ModelState.IsValid)
     {
         SetViewBag(Int32.Parse(model.idCategory));
         var kq = new FoodHandle().UpdateFood(model, model.id);
         if (kq)
         {
             SetAlert("Sửa món thành công", "success");
             return(Redirect("/Food/DSFood"));
         }
     }
     SetViewBag();
     return(View(model));
 }
Ejemplo n.º 4
0
 public ActionResult Food(Food model)
 {
     lsF = new FoodHandle().GetListFood();
     Server.HtmlEncode(model.detail);
     if (ModelState.IsValid)
     {
         string id = (Int32.Parse(lsF[lsF.Count - 1].id) + 1).ToString();
         SetViewBag(Int32.Parse(model.idCategory));
         model.id = id;
         var kq = new FoodHandle().AddFood(model, id);
         if (kq)
         {
             SetAlert("Thêm món thành công", "success");
             return(Redirect("/Food/DSFood"));
         }
     }
     SetViewBag();
     return(View(model));
 }