/// <summary> /// this method is used to get all the official details of employee /// </summary> /// <param name="employeeId">emloyee id </param> public async Task <EditEmployeeOfficialInformationDto> GetEmployeeOfficialDetails(Guid employeeId) { var employeeDetails = await _employeeRepository.GetEmployeeByIdAsync(employeeId); var empDepartmentDesignationId = employeeDetails.DepartmentDesignationId; if (empDepartmentDesignationId == 0) { throw new Exception("NotFound.Employee not found"); } var departmentId = await _departmentDesignationRepository.GetDepartmentByDepartmentDesignation(empDepartmentDesignationId); var department = await _departmentDesignationRepository.GetDepartmentById(departmentId); var departmentName = department.Name; var designationId = await _departmentDesignationRepository.GetDesignationByDepartmentDesignation(empDepartmentDesignationId); var designation = await _departmentDesignationRepository.GetDesignationById(designationId); var designationName = designation.Title; var employeeSkills = await _employeeSkillRepository.GetEmployeeSkills(employeeId); var reportingManager = await _reportingManagerRepository.GetReportingManager(employeeId); var result = _mapper.Map <EditEmployeeOfficialInformationDto>(employeeDetails); result.Designation = new DesignationUpdateDto { Id = designationId, Title = designationName }; result.Department = new DepartmentUpdateDto { Id = departmentId, Name = departmentName }; if (result.Languages.Count > 0) { result.Languages = JsonConvert.DeserializeObject <List <string> >(employeeDetails.Languages); } if (employeeSkills != null) { result.PrimarySkill = JsonConvert.DeserializeObject <List <string> >(employeeSkills.PrimarySkills); result.SecondarySkill = JsonConvert.DeserializeObject <List <string> >(employeeSkills.SecondarySkills); } result.ReportingManager = new GetEmployeeListDto(); if (reportingManager != null) { var reportingManagerDetails = new GetEmployeeListDto(); var reportingManagerName = await GetEmployeeNameById((Guid)reportingManager.ReportingManagerId); if (reportingManagerName != null) { reportingManagerDetails = new GetEmployeeListDto { Id = (Guid)reportingManager.ReportingManagerId, Name = reportingManagerName }; } result.ReportingManager = reportingManagerDetails; } return(result); }
public async Task <Department> GetDepartment(int departmentDesignationId) { var departmentDetails = await _departmentDesignationRepository.GetDepartmentByDepartmentDesignation(departmentDesignationId); var department = await _departmentRepository.GetDepartmentDetailsAsync(departmentDetails); return(department); }