public ActionResult Blended()
        {
            var product = new FoodDao();

            ViewBag.DS_Blended = product.ListBlended();
            return(View());
        }
Пример #2
0
        // GET: Khachhang
        public ActionResult KhachHang()
        {
            var dao = new FoodDao();

            ViewBag.ListTS = dao.ListTraSua();
            return(View());
        }
        public ActionResult Tea()
        {
            var product = new FoodDao();

            ViewBag.DS_Tea = product.ListTea();
            return(View());
        }
        // GET: Admin/Food
        public ActionResult DSFood(int page = 1, int pagesize = 10)
        {
            var accDao = new FoodDao();
            var model  = accDao.ListFoodAll(page, pagesize);

            return(View(model));
        }
        // GET: Food
        public ActionResult Cookies()
        {
            var product = new FoodDao();

            ViewBag.DS_Banh = product.ListFood();
            return(View());
        }
        public ActionResult Coffee()
        {
            var product = new FoodDao();

            ViewBag.DS_Cafe = product.ListCafe();
            return(View());
        }
Пример #7
0
        // GET: Food
        public ActionResult Detail(int foodId)
        {
            var  dao  = new FoodDao();
            Food food = dao.getById(foodId);

            return(View(food));
        }
Пример #8
0
        // GET: Menu
        public ActionResult Index(string search, int?page)
        {
            var         dao      = new FoodDao();
            List <Food> foodList = dao.search(search);

            return(View(foodList.ToPagedList(page ?? 1, 8)));
        }
Пример #9
0
        public ActionResult addToCart(int foodId)
        {
            if (Session[CommonConstant.CART_SESSION] == null)
            {
                Session[CommonConstant.CART_SESSION] = new CartModel();
            }
            CartModel cartModel = Session[CommonConstant.CART_SESSION] as CartModel;
            bool      flag      = false;

            if (cartModel.cart != null)
            {
                for (int i = 0; i < cartModel.cart.Count; i++)
                {
                    if (cartModel.cart.ElementAt(i).Key.ID == foodId)
                    {
                        flag = true;
                        Food index = cartModel.cart.ElementAt(i).Key;
                        cartModel.cart[index]++;
                        break;
                    }
                }
            }
            if (!flag)
            {
                FoodDao dao      = new FoodDao();
                Food    foodItem = dao.getById(foodId);
                cartModel.cart.Add(foodItem, 1);
            }
            tongTien();
            return(RedirectToAction("Index", "Cart"));
        }
Пример #10
0
        public Food getFood(int id)
        {
            var  dao  = new FoodDao();
            Food food = dao.getById(id);

            return(food);
        }
        public ActionResult Food(int id)
        {
            var food = new FoodDao().GetFood(id);

            ViewBag.RelatedFood = new FoodDao().RelatedFood(id);
            return(View(food));
        }
        public ActionResult Edit(int id)
        {
            var dao  = new FoodDao();
            var food = dao.GetFood(id);

            SetViewBag(food.IDCaterogy);
            return(View(food));
        }
Пример #13
0
        public RestfulData <Food> Get(int id)
        {
            var data = new FoodDao().Get(id);

            data.imgList = new ImageDao().GetImageList(id, 1);
            return(new RestfulData <Food>
            {
                data = data
            });
        }
        public JsonResult ListName(string q)
        {
            var data = new FoodDao().ListName(q);

            return(Json(new
            {
                data = data,
                status = true
            }, JsonRequestBehavior.AllowGet));
        }
Пример #15
0
        //GET:Update
        public ActionResult UpdateMenu(string search, int?page)
        {
            if (!check())
            {
                return(RedirectToAction("Login", "User"));
            }
            var         dao      = new FoodDao();
            List <Food> foodList = dao.search(search);

            return(View(foodList.ToPagedList(page ?? 1, 8)));
        }
Пример #16
0
        public ActionResult UpdateItem(int foodId)
        {
            if (!check())
            {
                return(RedirectToAction("Login", "User"));
            }
            var  dao  = new FoodDao();
            Food food = dao.getById(foodId);

            return(View(food));
        }
Пример #17
0
        public ActionResult DeleteFoodAction(int id)
        {
            var dao = new FoodDao();

            if (dao.Remove(dao.getById(id)))
            {
                return(RedirectToAction("DeleteFood"));
            }
            else
            {
                return(RedirectToAction("DeleteFood"));
            }
        }
Пример #18
0
        public RestfulArray <Food> GetFoodList(int page, int pageSize)
        {
            var foodList = new FoodDao().GetListPaged(page, pageSize, null, null);

            foreach (var item in foodList)
            {
                item.imgList = new ImageDao().GetImageList(item.Id, 2);
            }
            return(new RestfulArray <Food>
            {
                data = foodList,
                total = new FoodDao().RecordCount()
            });
        }
Пример #19
0
        public RestfulData PostFood([FromBody] Food food)
        {
            int foodId = new FoodDao().insertFood(food) ?? 0;

            if (foodId != 0)
            {
                new ImageDao().InsertImageList(food.imgList, food.Id, 1);
            }

            return(new RestfulData
            {
                message = "新增成功"
            });
        }
Пример #20
0
        public ActionResult Delete(int id)
        {
            bool result = new FoodDao().Delete(id);

            if (result)
            {
                return(Redirect("/Admin/Food/DSFood"));;
            }
            else
            {
                ModelState.AddModelError("", "Xóa món thất bại");
            }
            return(Redirect("/Admin/Food/DSFood"));;
        }
Пример #21
0
 public ActionResult Edit(TS model)
 {
     if (ModelState.IsValid)
     {
         SetViewBag(model.MaTS);
         var kq = new FoodDao().Update(model);
         if (kq)
         {
             return(Redirect("/Admin/Food/DSFood"));
         }
     }
     SetViewBag(model.MaTS);
     return(View(model));
 }
 public ActionResult Edit(ThucUong model)
 {
     if (ModelState.IsValid)
     {
         SetViewBag(model.IDCaterogy);
         var kq = new FoodDao().Update(model);
         if (kq)
         {
             SetAlert("Sửa món thành công", "success");
             return(Redirect("/Admin/Food/DSFood"));
         }
     }
     SetViewBag();
     return(View(model));
 }
Пример #23
0
        public ActionResult AddFoodAction(Food food)
        {
            FoodDao dao = new FoodDao();

            if (ModelState.IsValid)
            {
                if (dao.Update(food) >= 0)
                {
                    return(RedirectToAction("UpdateMenu"));
                }
                else
                {
                    ModelState.AddModelError("", "");
                }
            }
            else
            {
                ModelState.AddModelError("", "");
            }
            return(View("AddFood"));
        }
Пример #24
0
        public ActionResult UpdateItemAction(Food model)
        {
            FoodDao dao = new FoodDao();

            if (ModelState.IsValid)
            {
                if (dao.Update(model) >= 0)
                {
                    return(RedirectToAction("UpdateMenu"));
                }
                else
                {
                    ModelState.AddModelError("", "Lỗi cập nhật");
                }
            }
            else
            {
                ModelState.AddModelError("", "Vui lòng điền đủ và chính xác các trường.");
            }
            return(View("UpdateItem", new { foodId = model.ID }));
        }
Пример #25
0
        public ActionResult AddItem(int maDoUong, int SoLuong)
        {
            var douong = new FoodDao().GetFood(maDoUong);
            var Cart   = Session[CartSession];

            if (Cart != null)
            {
                var list = (List <CartItem>)Cart;
                if (list.Exists(x => x.Monan.MaTS == maDoUong))
                {
                    foreach (var item in list)
                    {
                        if (item.Monan.MaTS == maDoUong)
                        {
                            item.SoLuong += SoLuong;
                        }
                    }
                }
                else
                {
                    var item = new CartItem();
                    item.Monan   = douong;
                    item.SoLuong = SoLuong;
                    list.Add(item);
                }
                Session[CartSession] = list;
            }
            else
            {
                var item = new CartItem();
                item.Monan   = douong;
                item.SoLuong = SoLuong;
                var list = new List <CartItem>();
                list.Add(item);
                Session[CartSession] = list;
            }
            return(RedirectToAction("Cart", "GioHang"));
        }