/// <summary>
        /// 修改
        /// </summary>
        /// <param name="requestModel"></param>
        /// <returns></returns>
        public BusinessBaseViewModel <string> Update(UpdateSystemSectionRequestModel requestModel)
        {
            var res = new BusinessBaseViewModel <string>()
            {
                Status = ResponseStatus.Fail
            };

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

            if (entity != null)
            {
                res.ErrorMessage = "部门名称已存在,不能重复添加";
                return(res);
            }

            entity = _systemSectionRepository.FirstOrDefault(x => x.Id == requestModel.Id);

            if (entity == null)
            {
                res.ErrorMessage = "部门不存在或已被删除";
                return(res);
            }

            entity.Name       = requestModel.Name;
            entity.Person     = requestModel.Person;
            entity.Enabled    = requestModel.Enabled;
            entity.Sort       = requestModel.Sort;
            entity.ModifyTime = DateTime.Now;
            entity.Remark     = requestModel.Remark;


            _systemSectionRepository.Update(entity);
            _systemSectionRepository.SaveChanges();

            res.Status = ResponseStatus.Success;
            return(res);
        }
Beispiel #2
0
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="requestModel"></param>
        /// <returns></returns>
        public ActionResult Update(UpdateSystemSectionRequestModel requestModel)
        {
            var ret = _systemSectionService.Update(requestModel);

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