Example #1
0
        public async Task <bool> UpdateEmployeeWFH(EmployeeWFHCreationDTO employeeWFHCreationDTO)
        {
            try
            {
                _logger.LogDebug("Payload employeeWFHCreationDTO = " + employeeWFHCreationDTO);
                var employeeWFHEntity        = _mapper.Map <EmployeeWFHEntity>(employeeWFHCreationDTO);
                var EmployeeWFHEntityRecords = await _employeeWFHRepository.GetEmployeeWFHAsync(employeeWFHEntity);

                bool isRecordCreated = false;
                if (EmployeeWFHEntityRecords.Count() > 0)
                {
                    //Update
                    isRecordCreated = await _employeeWFHUpdateRepository.UpdateEmployeeWFH(employeeWFHEntity);
                }
                else
                {
                    //Add/Insert
                    var newWFHRecordCreatedID = await _employeeWFHUpdateRepository.AddEmployeeWFH(employeeWFHEntity);
                }
                //var employeeWFHEntityAdded = await _employeeWFHRepository.GetEmployeeWFHByPrimaryKeyId(newWFHRecordCreatedID);
                //var employeeWFHResponseDTO = _mapper.Map<EmployeeWFHResponseDTO>(employeeWFHEntityAdded);
                return(isRecordCreated);
            }
            catch (Exception ex)
            {
                _logger.LogError("Exception occured while calling AddEmployeeWFH method" + ex);
                throw;
            }
        }
        public async Task <IEnumerable <EmployeeWFHResponseDTO> > GetEmployeeWFH(EmployeeWFHRequestDTO employeeWFHRequestDTO)
        {
            try
            {
                _logger.LogInformation("Performing Service operation GetEmployeeWFH");
                var employeeWFHEntity = _mapper.Map <EmployeeWFHEntity>(employeeWFHRequestDTO);
                _logger.LogInformation("Calling Repository operation GetEmployeeWFHAsync ");
                var listEmployeeWFHEntities = await _employeeWFHRepository.GetEmployeeWFHAsync(employeeWFHEntity);

                _logger.LogDebug("Payload returned List of all employees WFH in a given date range for a specific vacationTypeId" + listEmployeeWFHEntities);
                var employeeWFHResponseDTO = _mapper.Map <IEnumerable <EmployeeWFHResponseDTO> >(listEmployeeWFHEntities);
                return(employeeWFHResponseDTO);
            }
            catch (Exception ex)
            {
                _logger.LogError("Exception occured while retrieving employee WFH data " + ex);
                throw;
            }
        }