示例#1
0
        private async Task <EmployeeTrainingsEntity> GetEmployeeTrainingsEntity(int id)
        {
            try
            {
                EmployeeTrainingsEntity employeeTrainingsEntity = await _employeeTrainingsRepository.GetEmployeeTrainingsByPrimaryKeyId(id);

                if (employeeTrainingsEntity == null)
                {
                    _logger.LogError("Record Not found and Null is returned whilst calling GetEmployeeTrainingsByPrimaryKeyId method from DeleteEmployeeTrainings having id - " + id);
                }
                return(employeeTrainingsEntity);
            }
            catch (Exception ex)
            {
                _logger.LogError($"Exception occured whilst calling a GetEmployeeTrainingsByPrimaryKeyId operation from DeleteEmployeeTrainings for id = {id} -->" + ex);
                throw;
            }
        }
        public async Task <EmployeeTrainingsResponseDTO> AddEmployeeTrainings(EmployeeTrainingsCreationDTO employeeTrainingsCreationDTO)
        {
            try
            {
                _logger.LogDebug("Payload employeeTrainingsCreationDTO = " + employeeTrainingsCreationDTO);
                var employeeTrainingsEntity    = _mapper.Map <EmployeeTrainingsEntity>(employeeTrainingsCreationDTO);
                var newTrainingRecordCreatedID = await _employeeTrainingsAddRepository.AddEmployeeTrainings(employeeTrainingsEntity);

                var employeeTrainingsEntityAdded = await _employeeTrainingsRepository.GetEmployeeTrainingsByPrimaryKeyId(newTrainingRecordCreatedID);

                var employeeTrainingsResponseDTO = _mapper.Map <EmployeeTrainingsResponseDTO>(employeeTrainingsEntityAdded);
                return(employeeTrainingsResponseDTO);
            }
            catch (Exception ex)
            {
                _logger.LogError("Exception occured while calling AddEmployeeTrainings method" + ex);
                throw;
            }
        }