Beispiel #1
0
        //Edit count of food
        // GET: Admin/BookFood/Edit/5
        public JsonResult Edit(string edit)
        {
            var give  = new JavaScriptSerializer().Deserialize <List <EditCount> >(edit);
            var count = (WebOrderTbRestaurant.Book_Menu.Book_Food[])Session["editCount"];
            var res   = new bool();

            foreach (var item in count)
            {
                foreach (var bok in give)
                {
                    if (bok.id == item.ID)
                    {
                        item.Count = bok.count;
                        res        = new BookMenuSVClient().EditCount(item.ID, item.Count);
                    }
                }
            }

            if (res)
            {
                SetAlert("Sửa số lượng món thành công", "success");
                return(Json(new { status = true }));
            }
            else
            {
                SetAlert("Sửa số lượng KHÔNG thành công", "error");
                return(Json(new { status = false }));
            }
        }
Beispiel #2
0
        // GET: Admin/BookFood/Delete/5
        public JsonResult DeleteInCus(long id)
        {
            var res = new BookMenuSVClient().deleteFoodinMenu(id);

            if (res)
            {
                SetAlert("Xóa món ăn trong thực đơn thành công", "success");
                return(Json(new { status = true }));
            }
            else
            {
                SetAlert("Xóa món ăn KHÔNG thành công", "error");
                return(Json(new { status = false }));
            }
        }
        // GET: Admin/Order
        public ActionResult Index(int page = 1, int pagesize = 2)
        {
            var or       = new OrderTB.OrderSVClient();
            var model    = or.ListAll().ToPagedList(page, pagesize); //Phân trang
            var order    = or.ListAll();
            var list     = new List <long>();
            var bookfood = new BookMenuSVClient();

            foreach (var item in order)
            {
                if (bookfood.CheckID(item.ID))
                {
                    list.Add(item.ID);//Lấy thực đơn của mỗi khách hàng
                }
            }
            ViewBag.IDorder = list;

            return(View(model));
        }
        //Lưu thực đơn và tên khách hàng đặt thực đơn
        public JsonResult SaveMenu(string Menu, string customer)
        {
            var menuJson = new JavaScriptSerializer().Deserialize <List <BookFood> >(Menu);
            var cusJson  = new JavaScriptSerializer().Deserialize <List <Feedback> >(customer);

            var feedback = new OrderTable();
            var listCus  = cusJson.ToList();

            foreach (var item in listCus)
            {
                if (item.Full_Name == null && item.Phone == null)
                {
                    SetAlert("Không thể bỏ trống HỌ VÀ TÊN và SỐ ĐIỆN THOẠI, vui lòng kiểm tra lại ", "warning");
                    break;
                    return(Json(new
                    {
                        status = true
                    }));
                }
                feedback.Full_Name = item.Full_Name;
                feedback.Phone     = item.Phone;
                feedback.Email     = item.Email;
                if (item.Description != " ")
                {
                    feedback.Description = item.Description;
                }
                feedback.DateBook     = item.DateBook;
                feedback.TimeBook     = item.TimeBook;
                feedback.Count_people = item.Count_people;
                feedback.CreatedDate  = DateTime.Now;

                var ins = new OrderSVClient();
                if (ins.Insert(feedback))
                {
                    SetAlert("Đặt bàn thành công", "success");
                }
                else
                {
                    SetAlert("Đặt bàn không thành công", "warning");
                }
            }


            var bookFood = new Book_Menu.Book_Food();
            var listFood = menuJson.ToList();
            var idOrder  = new OrderSVClient().FindIDNew();

            foreach (var item in listFood)
            {
                bookFood.Food_ID       = item.Food_ID;
                bookFood.Count         = item.Count;
                bookFood.Price         = Convert.ToDecimal(item.Price);
                bookFood.OrderTable_ID = idOrder;

                var ins = new BookMenuSVClient();
                if (ins.InsertMenu(bookFood))
                {
                    SetAlert("Bạn đã đặt trước thực đơn thành công", "success");
                }
                else
                {
                    SetAlert("Bạn đã đặt trước thực đơn không thành công", "warning");
                }
            }
            return(Json(new
            {
                status = true
            }));
        }