コード例 #1
0
ファイル: MenusController.cs プロジェクト: chipdlk/THD
        public ActionResult SaveItem(MenusModel model)
        {
            string     ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
            int        IdDC           = Int32.Parse(MyModels.Decode(model.Item.Ids, API.Models.Settings.SecretId + ControllerName).ToString());
            MenusModel data           = model;

            if (ModelState.IsValid)
            {
                if (model.Item.Id == IdDC)
                {
                    model.Item.ModifiedBy = int.Parse(HttpContext.Request.Headers["Id"]);
                    MenusService.SaveItem(model.Item);
                    if (model.Item.Id > 0)
                    {
                        TempData["MessageSuccess"] = "Cập nhật thành công";
                    }
                    else
                    {
                        TempData["MessageSuccess"] = "Thêm mới thành công";
                    }
                    return(RedirectToAction("Index", new { IdCoQuan = model.Item.IdCoQuan }));
                }
            }
            data.ListType = MenusService.GetListType();
            return(View(data));
        }
コード例 #2
0
ファイル: MenusController.cs プロジェクト: chipdlk/THD
        public IActionResult SaveItem(string Id = null, int IdCoQuan = 1)
        {
            MenusModel data           = new MenusModel();
            string     ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString();

            int IdDC = Int32.Parse(MyModels.Decode(Id, API.Models.Settings.SecretId + ControllerName).ToString());

            data.SearchData = new SearchMenus()
            {
                CurrentPage = 0, ItemsPerPage = 10, Keyword = "", IdCoQuan = IdCoQuan
            };
            data.ListItemsArticle       = ArticlesService.GetListStaticArticle();
            data.ListType               = MenusService.GetListType();
            data.ListCategoriesArticles = CategoriesArticlesService.GetList();
            data.ListCategoriesProducts = ProductsCategoriesService.GetList();
            data.ListItemsMenus         = MenusService.GetListItems(true, IdCoQuan);

            if (IdDC == 0)
            {
                data.Item = new Menus();
            }
            else
            {
                data.Item = MenusService.GetItem(IdDC, API.Models.Settings.SecretId + ControllerName);
            }


            return(View(data));
        }