Exemple #1
0
        public async Task <ViewResultBase> Edit(SystemMenuEditInput input)
        {
            var menuDto = new SystemMenuEditOutput();

            //如果为编辑
            if (!input.Id.IsEmptyGuid())
            {
                var menu = await _menuLogic.GetByIdAsync(input.Id);

                menuDto = menu.MapTo <SystemMenuEditOutput>();

                //获取父级信息
                var parentInfo = await _menuLogic.GetByIdAsync(menuDto.ParentId);

                if (parentInfo != null)
                {
                    menuDto.ParentName = parentInfo.Name;
                    menuDto.ParentCode = parentInfo.Code;
                }
            }
            //新增
            else
            {
                if (!input.ParentId.IsEmptyGuid())
                {
                    var parentInfo = await _menuLogic.GetByIdAsync(input.ParentId);

                    menuDto.Code       = parentInfo.Code;
                    menuDto.ParentId   = input.ParentId;
                    menuDto.ParentName = parentInfo.Name;
                    menuDto.ParentCode = parentInfo.Code;
                }
            }
            return(View(menuDto));
        }
        public async Task <JsonResult> GetById(IdInput input)
        {
            var menuDto = new SystemMenuEditOutput();

            //如果为编辑
            if (!input.Id.IsEmptyGuid())
            {
                var menu = await _menuLogic.GetByIdAsync(input.Id);

                menuDto = menu.MapTo <SystemMenuEditOutput>();
                //获取父级信息
                var parentInfo = await _menuLogic.GetByIdAsync(menuDto.ParentId);

                if (parentInfo != null)
                {
                    menuDto.ParentName = parentInfo.Name;
                }
            }
            return(Json(menuDto));
        }