コード例 #1
0
        public BusinessBaseViewModel <string> Update(UpdateSystemMenuRequestModel requestModel)
        {
            var res = new BusinessBaseViewModel <string>()
            {
                Status = ResponseStatus.Fail
            };

            if (requestModel == null)
            {
                res.ErrorMessage = "参数错误";
                return(res);
            }
            if (requestModel.Id <= 0)
            {
                res.ErrorMessage = "Id不能为空";
                return(res);
            }
            if (requestModel.MenuName.IsNullOrWhiteSpace())
            {
                res.ErrorMessage = "菜单名称不能为空";
                return(res);
            }
            if (requestModel.Level <= 0)
            {
                res.ErrorMessage = "菜单层级不能为空";
                return(res);
            }
            if (requestModel.MenuSort <= 0)
            {
                res.ErrorMessage = "菜单排序不能为空";
                return(res);
            }

            var menuEntity = _systemMenuRepository.FirstOrDefault(x => x.Id == requestModel.Id);

            if (menuEntity == null)
            {
                res.ErrorMessage = "菜单不存在或已删除";
                return(res);
            }

            menuEntity.Level        = requestModel.Level;
            menuEntity.MenuButtonId = requestModel.MenuButtonId;
            menuEntity.MenuDesc     = requestModel.MenuDesc;
            menuEntity.MenuIcon     = requestModel.MenuIcon;
            menuEntity.MenuName     = requestModel.MenuName;
            menuEntity.MenuSort     = requestModel.MenuSort;
            menuEntity.MenuUrl      = requestModel.MenuUrl;
            menuEntity.ParentId     = requestModel.ParentId;
            menuEntity.ModifyTime   = DateTime.Now;

            _systemMenuRepository.Update(menuEntity);
            _systemMenuRepository.SaveChanges();

            res.Status = ResponseStatus.Success;
            return(res);
        }
コード例 #2
0
        public ActionResult Update(UpdateSystemMenuRequestModel requestModel)
        {
            var res = _systemMenuService.Update(requestModel);

            return(Content(res.ToJsonString()));
        }