コード例 #1
0
        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="employeeRequestDto"></param>
        /// <returns></returns>
        public async Task <bool> CreateAsync(EmployeeRequestDto employeeRequestDto)
        {
            var employee = employeeRequestDto.MapToCreateEntity <EmployeeRequestDto, Employee>();
            await EmployeeValidatorsFilter.DoValidationAsync(_employeeRespository, employee, ValidatorTypeConstants.Create);

            return(await _employeeRespository.InsertAsync(employee));
        }
コード例 #2
0
        /// <summary>
        /// 批量新增
        /// </summary>
        /// <param name="employeeRequestDtos"></param>
        /// <returns></returns>
        public async Task <bool> BatchCreateAsync(IList <EmployeeRequestDto> employeeRequestDtos)
        {
            var entities = employeeRequestDtos.MapToCreateEntities <EmployeeRequestDto, Employee>();
            await EmployeeValidatorsFilter.DoValidationAsync(_employeeRespository, entities, ValidatorTypeConstants.Create);

            await _employeeRespository.BatchInsertAsync(entities);

            return(true);
        }
コード例 #3
0
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="employeeRequestDto"></param>
        /// <returns></returns>
        public async Task <bool> ModifyAsync(EmployeeRequestDto employeeRequestDto)
        {
            var employee = await _employeeRespository.FirstOrDefaultAsync(e => e.Id == employeeRequestDto.Id);

            employeeRequestDto.Password = employee.Password;
            employeeRequestDto.Salt     = employee.Salt;
            var entity = employeeRequestDto.MapToModifyEntity <EmployeeRequestDto, Employee>(employee);
            await EmployeeValidatorsFilter.DoValidationAsync(_employeeRespository, entity, ValidatorTypeConstants.Modify);

            return(await _employeeRespository.UpdateAsync(entity));
        }
コード例 #4
0
        /// <summary>
        /// 批量修改
        /// </summary>
        /// <param name="employeeRequestDtos"></param>
        /// <returns></returns>
        public async Task <bool> BatchModifyAsync(IList <EmployeeRequestDto> employeeRequestDtos)
        {
            var ids       = employeeRequestDtos.Select(m => m.Id).ToList();
            var employees = await _employeeRespository.EntitiesByExpressionAsync(e => ids.Contains(e.Id));

            var entities = employeeRequestDtos.MapToModifyEntities <EmployeeRequestDto, Employee>(employees.ToList());
            await EmployeeValidatorsFilter.DoValidationAsync(_employeeRespository, entities, ValidatorTypeConstants.Create);

            await _employeeRespository.BatchUpdateAsync(entities);

            return(true);
        }