Beispiel #1
0
        public ActionResult Edit(int id)
        {
            var entity = SysActionService.GetList(x => x.Id == id).FirstOrDefault();

            SysActionMenuService.GetList(x => x.Id == id).FirstOrDefault();
            SysActionButtonService.GetList(x => x.Id == id).FirstOrDefault();
            var viewModel = entity.EntityMap();

            if (viewModel.Type == ActionTypeEnum.Menu)
            {
                return(View("EditMenu", viewModel));
            }
            else if (viewModel.Type == ActionTypeEnum.Button)
            {
                return(View("EditButton", viewModel));
            }
            else
            {
                return(View());
            }
        }
Beispiel #2
0
        public ActionResult Edit(ActionViewModel viewModel)
        {
            if (ModelState.IsValid == false)
            {
                return(WriteError("实体验证失败"));
            }
            var action = SysActionService.GetList(x => x.Id == viewModel.Id).FirstOrDefault();

            SysActionMenuService.GetList(x => x.Id == viewModel.Id).FirstOrDefault();
            SysActionButtonService.GetList(x => x.Id == viewModel.Id).FirstOrDefault();
            if (action != null)
            {
                action.Name         = viewModel.Name;
                action.ParentId     = viewModel.ParentId;
                action.Code         = viewModel.Code;
                action.Type         = viewModel.Type;
                action.SortCode     = viewModel.SortCode;
                action.UpdateTime   = DateTime.Now;
                action.UpdateUserId = UserManager.GetCurrentUserInfo().Id;
                if (viewModel.Type == ActionTypeEnum.Menu)
                {
                    action.SysActionMenu.Icon = viewModel.Icon;
                    action.SysActionMenu.Url  = viewModel.Url;
                }
                else if (viewModel.Type == ActionTypeEnum.Button)
                {
                    action.SysActionButton.ButtonCode  = viewModel.Code;
                    action.SysActionButton.Location    = viewModel.Location;
                    action.SysActionButton.ButtonClass = viewModel.ButtonClass;
                    action.SysActionButton.ButtonIcon  = viewModel.ButtonIcon;
                }
                else
                {
                    return(WriteError("类型不正确"));
                }
                SysActionService.Update(action);
                return(WriteSuccess());
            }
            return(WriteError());
        }