Exemple #1
0
        public ActionResult UpdateFunctionMenu(Menu menu)
        {
            Menu newMenu = OpeCur.BllServices.MenuService.LoadEntities(c => c.MenuId == menu.MenuId).FirstOrDefault();

            if (newMenu != null)
            {
                newMenu.MenuName       = menu.MenuName;
                newMenu.Method         = menu.Method;
                newMenu.OrderNo        = menu.OrderNo;
                newMenu.Type           = menu.Type;
                newMenu.ActionName     = menu.ActionName;
                newMenu.Area           = menu.Area;
                newMenu.ControllerName = menu.ControllerName;
                newMenu.ToolIco        = menu.ToolIco;

                MenuValidation validator = new MenuValidation();
                menu.IsDelete = false;
                var results = validator.Validate(newMenu);

                if (!results.IsValid)
                {
                    return(OpeCur.AjaxMsgNOOK(results.Errors[0].ErrorMessage));
                }
                OpeCur.BllServices.MenuService.Update(newMenu);
                if (OpeCur.BllServices.SaveChange() > 0)
                {
                    return(OpeCur.AjaxMsgOK("更新成功"));
                }
            }

            return(OpeCur.AjaxMsgNOOK("更新失败"));
        }
        public string AddOrModify([FromForm] MenuAddOrModifyModel item)
        {
            var              result          = new BaseResult();
            MenuValidation   validationRules = new MenuValidation();
            ValidationResult results         = validationRules.Validate(item);

            if (results.IsValid)
            {
                //result = _service.AddOrModify(item);
            }
            else
            {
                result.ResultCode = ResultCodeAddMsgKeys.CommonModelStateInvalidCode;
                result.ResultMsg  = results.ToString("||");
            }
            return(JsonHelper.ObjectToJSON(result));
        }
Exemple #3
0
        public ActionResult AddFunctionMenu(Menu menu)
        {
            MenuValidation validator = new MenuValidation();

            menu.IsDelete = false;
            var results = validator.Validate(menu);

            if (!results.IsValid)
            {
                return(OpeCur.AjaxMsgNOOK(results.Errors[0].ErrorMessage));
            }

            OpeCur.BllServices.MenuService.Insert(menu);
            if (OpeCur.BllServices.SaveChange() > 0)
            {
                return(OpeCur.AjaxMsgOK("添加成功"));
            }
            return(OpeCur.AjaxMsgNOOK("添加失败"));
        }