示例#1
0
        /// <summary>
        /// 编辑
        /// </summary>
        /// <returns></returns>
        public ActionResult Edit(QueryDetailSystemSectionRequestModel requestModel)
        {
            var res = _systemSectionService.QueryDetail(requestModel);

            if (res != null && res.BusinessData != null)
            {
                if (res.BusinessData.ParentId == 0)
                {
                    ViewBag.pName = "顶级";
                }
                else
                {
                    requestModel.Id = res.BusinessData.ParentId;

                    var entity = _systemSectionService.QueryDetail(requestModel);

                    ViewBag.pName = entity.BusinessData.Name;
                }
            }

            return(View(res.BusinessData));
        }
        /// <summary>
        /// 查询明细
        /// </summary>
        /// <param name="requestModel"></param>
        /// <returns></returns>
        public BusinessBaseViewModel <QueryDetailSystemSectionResponseModel> QueryDetail(QueryDetailSystemSectionRequestModel requestModel)
        {
            var res = new BusinessBaseViewModel <QueryDetailSystemSectionResponseModel>()
            {
                Status = ResponseStatus.Fail
            };

            if (requestModel == null)
            {
                res.ErrorMessage = "参数错误";
                return(res);
            }
            if (requestModel.Id <= 0)
            {
                res.ErrorMessage = "部门Id不能为空";
                return(res);
            }
            var entity = _systemSectionRepository.FirstOrDefault(x => x.Id == requestModel.Id);

            if (entity == null)
            {
                res.ErrorMessage = "部门不存在或已被删除";
                return(res);
            }
            res.BusinessData = entity.MapTo <QueryDetailSystemSectionResponseModel>();
            res.Status       = ResponseStatus.Success;
            return(res);
        }