Example #1
0
        public async Task SaveDept(SysDeptDto deptDto)
        {
            if (string.IsNullOrWhiteSpace(deptDto.FullName))
            {
                throw new BusinessException((int)ErrorCode.BadRequest, "请输入部门全称");
            }

            if (string.IsNullOrWhiteSpace(deptDto.SimpleName))
            {
                throw new BusinessException((int)ErrorCode.BadRequest, "请输入部门简称");
            }

            if (deptDto.ID == 0)
            {
                var dept = _mapper.Map <SysDept>(deptDto);
                await this.SetDeptPids(dept);

                await _deptRepository.InsertAsync(dept);
            }
            else
            {
                var oldDept = await _deptRepository.FetchAsync(x => x.ID == deptDto.ID);

                oldDept.Pid        = deptDto.Pid;
                oldDept.SimpleName = deptDto.SimpleName;
                oldDept.FullName   = deptDto.FullName;
                oldDept.Num        = deptDto.Num;
                oldDept.Tips       = deptDto.Tips;
                await this.SetDeptPids(oldDept);

                await _deptRepository.UpdateAsync(oldDept);
            }
        }
Example #2
0
 public async Task SaveDept(SysDeptDto deptDto)
 {
     await _deptService.SaveDept(deptDto);
 }