public ViewResult ShowPost(
            int id   = 1,
            int page = 1,
            int row  = 20
            )
        {
            var areaDb   = new AreaDb();
            var listArea = areaDb.GetAll();

            ViewBag.listArea = listArea;
            var listAreaChild = areaDb.GetListAreaById(1);

            ViewBag.listAreaChild = listAreaChild;

            var menuListModel = new MenuListModels();

            if (Session["ListOfPost"] != null)
            {
                menuListModel = (MenuListModels)Session["ListOfPost"];
            }

            var newsDb = new NewsDb();
            var menuDb = new MenuDb();
            int intCount;

            menuListModel.MenuId    = id;
            menuListModel.MenuName  = menuDb.GetMenuById(id).Name;
            menuListModel.newsModel = newsDb.SearchNews(out intCount, menuListModel.TinhThanhId, menuListModel.QuanHuyenId, menuListModel.Title, menuListModel.Price, page, row, id);

            ViewBag.NumberOfPages = intCount / row + (intCount % row > 0 ? 1 : 0);
            ViewBag.CurrentPage   = page;
            ViewBag.MenuId        = id;
            return(View(menuListModel));
        }
        public void DeleteMenu(int menuId)
        {
            var menuDb   = new MenuDb();
            var menuCtrl = new MenuCtrl();

            menuDb.DeleteMenu(menuId);
        }
        public ViewResult CreateMenu()
        {
            //Get Parent Menu
            var menu = new MenuDb();

            ViewBag.ListParentMenu = menu.GetParentMenu();
            return(View());
        }
        public ActionResult CreateMenu(MenuModels menuModels)
        {
            var menuDb = new MenuDb();

            menuModels = menuDb.Add(menuModels);
            RefreshMenu();
            Session["AddMenuSuccessMessage"] = "Thêm menu thành công!";
            return(RedirectToAction("EditMenu", "Home", new { @Id = menuModels.Id }));
        }
Exemple #5
0
        public void UpdateMenu(ModelLibrary.Menu beforeMenu, ModelLibrary.Menu afterMenu)
        {
            var menuDb = new MenuDb();

            var beforeDbMenu = ConvertMenuToDb(beforeMenu);
            var afterDbMenu  = ConvertMenuToDb(afterMenu);

            menuDb.UpdateMenu(beforeDbMenu, afterDbMenu);
        }
Exemple #6
0
        public async Task <IActionResult> DeleteConfirmed(int id)
        {
            Reservation res = await MenuDb.GetReservationById(id, _context);

            await MenuDb.DeleteReservation(res, _context);

            TempData["Message"] = $"{res.EventName} deleted successfully";
            return(RedirectToAction("FoodTruckReservation", "Reservation"));
        }
Exemple #7
0
        public async Task <IActionResult> DeleteConfirmed(int id)
        {
            FoodItem food = await MenuDb.GetFoodItemById(id, _context);

            await MenuDb.Delete(food, _context);

            TempData["Message"] = $"{food.ItemName} deleted successfully";
            return(RedirectToAction(nameof(FoodTruckMenu)));
        }
        public JsonResult DeleteMenu(int Id)
        {
            var id     = Id;
            var menuDb = new MenuDb();

            menuDb.DeleteMenuById(Id);
            RefreshMenu();
            return(Json("Delete complete", JsonRequestBehavior.AllowGet));
        }
Exemple #9
0
        public ActionResult <ApiResult <List <Menu> > > GetMenu()
        {
            var list   = MenuDb.AsQueryable().ToTree(it => it.Child, it => it.ParentId, null);
            var result = new ApiResult <List <Menu> >();

            result.Data      = list;
            result.IsSuccess = true;
            return(result);
        }
        public ActionResult EditMenu(MenuModels menuModels)
        {
            var menuDb = new MenuDb();

            menuDb.Update(menuModels);
            ViewBag.ListParentMenu = menuDb.GetParentMenu();
            RefreshMenu();
            Session["AddMenuSuccessMessage"] = "Sửa menu thành công!";
            return(View(menuModels));
        }
Exemple #11
0
        public ModelLibrary.Menu GetActiveMenu(int restaurantId)
        {
            var menuDb   = new MenuDb();
            var itemCtrl = new ItemCtrl();

            var menu = ConvertMenuToModel(menuDb.GetActiveMenu(restaurantId));

            menu.Items = itemCtrl.GetMenuItems(menu.Id);
            return(menu);
        }
Exemple #12
0
        public async Task <IActionResult> Delete(int id)
        {
            Reservation res = await MenuDb.GetReservationById(id, _context);

            if (res == null)
            {
                return(NotFound());
            }

            return(View(res));
        }
Exemple #13
0
        public async Task <IActionResult> Delete(int id)
        {
            FoodItem food = await MenuDb.GetFoodItemById(id, _context);

            if (food == null)
            {
                return(NotFound());
            }

            return(View(food));
        }
        public ViewResult EditMenu(int Id = 1)
        {
            //Get Parent Menu
            var menuDb = new MenuDb();

            ViewBag.ListParentMenu = menuDb.GetParentMenu();
            //GetMenuById
            var model = menuDb.GetMenuById(Id);

            return(View(model));
        }
Exemple #15
0
        public async Task <IActionResult> EditReservation(Reservation res)
        {
            if (ModelState.IsValid)
            {
                await MenuDb.EditReservation(res, _context);

                ViewData["Message"] = res.EventName + " updated successfully";
            }

            return(View(res));
        }
Exemple #16
0
        public async Task <IActionResult> Edit(FoodItem food)
        {
            if (ModelState.IsValid)
            {
                await MenuDb.Edit(food, _context);

                ViewData["Message"] = food.ItemName + " updated successfully";
                return(View(food));
            }

            return(View(food));
        }
Exemple #17
0
        public async Task <IActionResult> AddReservation(Reservation res)
        {
            if (ModelState.IsValid)
            {
                await MenuDb.Add(res, _context);

                TempData["Message"] = $"{res.EventName} added successfully";
                // Had to redirect forcefully to the main menu for food truck
                return(RedirectToAction("FoodTruckReservation", "Reservation"));
            }
            return(View());
        }
Exemple #18
0
        public async Task <IActionResult> Add(FoodItem food)
        {
            if (ModelState.IsValid)
            {
                await MenuDb.Add(food, _context);

                TempData["Message"] = $"{food.ItemName} added successfully";
                return(RedirectToAction(nameof(FoodTruckMenu)));
            }

            return(View());
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            menu = new MenuDb();

            dataSource = menu.GetMenu();

            if (!this.IsPostBack)
            {
                menuList.DataSource = dataSource;
                menuList.DataBind();
            }
        }
Exemple #20
0
        public ModelLibrary.Menu GetMenuByName(string name)
        {
            var menuDb = new MenuDb();
            var menu   = menuDb.GetMenuByName(name);

            ModelLibrary.Menu newMenu = null;
            var modelMenu             = ConvertMenuToModel(menu);

            if (menu != null)
            {
                return(modelMenu);
            }
            return(newMenu);
        }
Exemple #21
0
        public ModelLibrary.Menu GetMenuById(int menuId)
        {
            var menuDb = new MenuDb();
            var menu   = menuDb.GetMenu(menuId);

            ModelLibrary.Menu newMenu = null;
            var modelMenu             = ConvertMenuToModel(menu);

            if (menu != null)
            {
                return(modelMenu);
            }
            return(newMenu);
        }
Exemple #22
0
        public async Task <IActionResult> EditReservation(int?id)
        {
            if (id == null)
            {
                return(BadRequest());
            }
            Reservation res = await MenuDb.GetReservationById(id.Value, _context);

            if (res == null)
            {
                return(NotFound());
            }

            return(View(res));
        }
        public ActionResult Index()
        {
            // Lay danh sach khu vuc
            var area = new AreaDb();

            ViewBag.areaList = area.GetAll();
            // Lay danh sach chuyen muc
            var menu             = new MenuDb();
            var listAll          = menu.GetAll();
            var listAfterConvert = Common.GetTree4Cbo(listAll, 0);

            Common.GetMenuSelectTag(listAfterConvert);
            ViewBag.categoryList = Common.ListMenuSelectTag.ToString();
            return(View());
        }
Exemple #24
0
        protected void btnAddMenu_Click(object sender, EventArgs e)
        {
            MenuDb menu = new MenuDb()
            {
                Title  = this.add_tbMenuTitle.Text,
                Link   = this.add_tbMenuLink.Text,
                IdRole = Convert.ToInt32(this.add_DropDownListMenuRole.SelectedValue)
            };

            this.GridViewMenus.DataSource = OperationManager.Singleton.izvrsiOperaciju(new OpMenuInsert()
            {
                Menu = menu
            }).DbItems.Cast <MenuDb>().ToArray();
            this.GridViewMenus.DataBind();
        }
Exemple #25
0
        public async Task <IActionResult> Edit(int?id)
        {
            if (id == null)
            {
                // HTTP 400
                return(BadRequest());
            }
            FoodItem food = await MenuDb.GetFoodItemById(id.Value, _context);

            if (food == null)
            {
                return(NotFound()); // returns a HTTP 404 - Not Found
                // return RedirectToAction("ShowAll"); // Returns the user to the ShowAll Page
            }

            return(View(food));
        }
        /// <summary>
        /// Refresh menu
        /// </summary>
        private void RefreshMenu()
        {
            var menuDb = new MenuDb();

            //Update menu again
            BdsCommon.ListMenuUlTag.Clear();
            BdsCommon.ListMenuSelectTag.Clear();
            BdsCommon.ListMenuBasic.Clear();
            var list             = menuDb.GetAll();
            var listAfterConvert = BdsCommon.GetTree(list, 0);

            BdsCommon.GetMenuUlTag(listAfterConvert);
            BdsCommon.GetMenuSelectTag(listAfterConvert);
            BdsCommon.GetMenuList(listAfterConvert);
            System.Web.HttpContext.Current.Session["UIConvert"] = BdsCommon.ListMenuUlTag.ToString();
            System.Web.HttpContext.Current.Session["UIMenu"]    = BdsCommon.ListMenuSelectTag.ToString();
        }
 public ActionResult Index()
 {
     if (System.Web.HttpContext.Current.Session["UIConvert"] == null)
     {
         var area = new AreaDb();
         ViewBag.areaList = area.GetAll();
         // Lay danh sach chuyen muc
         var menu             = new MenuDb();
         var listAll          = menu.GetAll();
         var listAfterConvert = BdsCommon.GetTree(listAll, 0);
         BdsCommon.GetMenuUlTag(listAfterConvert);
         BdsCommon.GetMenuSelectTag(listAfterConvert);
         //Common.SaveDataToResource("NavCategory", Common.ListMenuSelectTag.ToString());
         ViewBag.categoryList = BdsCommon.ListMenuSelectTag.ToString();
     }
     return(View());
 }
        public IEnumerable <Menu> SearchMenu(Expression <Func <Menu, bool> > whereExpressions, PageOptions page)
        {
            var query = whereExpressions == null?MenuDb.AsQueryable() : MenuDb.AsQueryable().Where(whereExpressions);

            if (!page.IsNull() && page.IsValidate)
            {
                var totalCount = 0;
                var results    = query.ToPageList(page.PageIndex, page.PageSize, ref totalCount);
                page.TotalCount = totalCount;

                return(results);
            }
            else
            {
                return(query.ToList());
            }
        }
        /// <summary>
        /// Check if you are logged in if not redirect you to login screen
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            menu = new MenuDb();

            dataSource = menu.GetMenu();

            if (HttpContext.Current.Session["Login"] != null)
            {
                Page.Visible        = true;
                menuList.DataSource = menu.GetMenu();
                menuList.DataBind();
            }
            else
            {
                Page.Visible = false;
                Response.Redirect("AdminLogin.aspx");
            }
        }
Exemple #30
0
        protected void ButtonUpdateMenu_Click(object sender, EventArgs e)
        {
            MenuDb menu = new MenuDb()
            {
                IdMenu           = Convert.ToInt32(this.LabelMenuId.Text),
                Link             = this.tbMenuLink.Text,
                Title            = this.tbMenuTitle.Text,
                IdRole           = Convert.ToInt32(this.DropDownListRole.SelectedValue),
                IdUserLastChange = (int)Session["idUser"]
            };

            this.GridViewMenus.DataSource = OperationManager.Singleton.izvrsiOperaciju(new OpMenuUpdate()
            {
                Menu = menu
            }).DbItems.Cast <MenuDb>().ToArray();
            this.GridViewMenus.DataBind();
            this.LabelMenuId.Text = "";
        }