Пример #1
0
        public ActionResult DeleteItem(string Id)
        {
            string ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
            USMenu item           = new USMenu()
            {
                Id = Int32.Parse(MyModels.Decode(Id, API.Models.Settings.SecretId + ControllerName).ToString())
            };

            try
            {
                if (item.Id > 0)
                {
                    item.CreatedBy = item.ModifiedBy = int.Parse(HttpContext.Request.Headers["Id"]);
                    USMenuService.DeleteItem(item);
                    TempData["MessageSuccess"] = "Xóa thành công";
                    return(Json(new MsgSuccess()));
                }
                else
                {
                    TempData["MessageError"] = "Xóa Không thành công";
                    return(Json(new MsgError()));
                }
            }
            catch {
                TempData["MessageSuccess"] = "Xóa không thành công";
                return(Json(new MsgError()));
            }
        }
Пример #2
0
        public ActionResult SaveItem(USMenu model)
        {
            string      ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
            int         IdDC           = Int32.Parse(MyModels.Decode(model.Ids, API.Models.Settings.SecretId + ControllerName).ToString());
            USMenuModel data           = new USMenuModel()
            {
                Item = model
            };

            if (ModelState.IsValid)
            {
                if (model.Id == IdDC)
                {
                    model.CreatedBy = model.ModifiedBy = int.Parse(HttpContext.Request.Headers["Id"]);
                    USMenuService.SaveItem(model);
                    if (model.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"));
                }
            }
            return(View(data));
        }