Example #1
0
        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="employeeElementRequestDto"></param>
        /// <returns></returns>
        public async Task <bool> CreateAsync(EmployeeElementRequestDto employeeElementRequestDto)
        {
            var employeeElement = _mapper.Map <EmployeeElementRequestDto, EmployeeElement>(employeeElementRequestDto);
            await EmployeeElementValidatorsFilter.DoValidationAsync(_employeeElementRespository, employeeElement, ValidatorTypeConstants.Create);

            return(await _employeeElementRespository.InsertAsync(employeeElement));
        }
Example #2
0
        /// <summary>
        /// 批量新增
        /// </summary>
        /// <param name="employeeElementRequestDtos"></param>
        /// <returns></returns>
        public async Task <bool> BatchCreateAsync(IList <EmployeeElementRequestDto> employeeElementRequestDtos)
        {
            var entities = employeeElementRequestDtos.MapToList <EmployeeElementRequestDto, EmployeeElement>();
            await EmployeeElementValidatorsFilter.DoValidationAsync(_employeeElementRespository, entities, ValidatorTypeConstants.Create);

            await _employeeElementRespository.BatchInsertAsync(entities);

            return(true);
        }
Example #3
0
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="employeeElementRequestDto"></param>
        /// <returns></returns>
        public async Task <bool> ModifyAsync(EmployeeElementRequestDto employeeElementRequestDto)
        {
            var employeeElement = await _employeeElementRespository.FirstOrDefaultAsync(e => e.Id == employeeElementRequestDto.Id);

            var entity = employeeElementRequestDto.MapToModifyEntity <EmployeeElementRequestDto, EmployeeElement>(employeeElement);
            await EmployeeElementValidatorsFilter.DoValidationAsync(_employeeElementRespository, entity, ValidatorTypeConstants.Modify);

            return(await _employeeElementRespository.UpdateAsync(entity));
        }
Example #4
0
        /// <summary>
        /// 批量删除
        /// </summary>
        /// <param name="employeeElementRequestDtos"></param>
        /// <returns></returns>
        public async Task <bool> BatchRemoveAsync(IList <EmployeeElementRequestDto> employeeElementRequestDtos)
        {
            var employeeIds      = employeeElementRequestDtos.Select(m => m.EmployeeId).ToList();
            var elementIds       = employeeElementRequestDtos.Select(m => m.ElementId).ToList();
            var employeeElements = await _employeeElementRespository.EntitiesByExpressionAsync(e => employeeIds.Contains(e.EmployeeId) &&
                                                                                               elementIds.Contains(e.ElementId) && e.IsDelete == false);

            var entities = employeeElementRequestDtos.MapToModifyEntities <EmployeeElementRequestDto, EmployeeElement>(employeeElements.ToList());
            await EmployeeElementValidatorsFilter.DoValidationAsync(_employeeElementRespository, entities, ValidatorTypeConstants.Create);

            await _employeeElementRespository.BatchUpdateAsync(entities);

            return(true);
        }