예제 #1
0
        /// <summary>
        /// 新增系别
        /// </summary>
        /// <param name="deptDto"></param>
        /// <returns></returns>
        public async Task <DeptDto> InsertDept(DeptDto deptDto)
        {
            // deptDto.CreateTime = TimeUtil.GetTimeStampNow();
            var dept = await _deptRepository.InsertNowAsync(deptDto.Adapt <TbDept>());

            return(dept.Entity.Adapt <DeptDto>());
        }
예제 #2
0
        /// <summary>
        /// 更新系别
        /// </summary>
        /// <param name="deptDto"></param>
        /// <returns></returns>
        /// <exception cref="Exception"></exception>
        public async Task <DeptDto> UpdateDept(DeptDto deptDto)
        {
            var dept = await _deptRepository.FirstOrDefaultAsync(x => x.Id == deptDto.Id);

            if (dept == null)
            {
                throw Oops.Oh(DeptErrorCodes.d1301);
            }
            var changeDept = deptDto.Adapt(dept);
            await changeDept.UpdateExcludeAsync(u => u.CreateTime);

            return(changeDept.Adapt <DeptDto>());
        }