/// <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);
        }
        /// <summary>
        /// this method will fetch all the members of the project
        /// </summary>
        /// <param name="projectId"></param>
        /// <returns></returns>
        public async Task <List <EmployeeBasicDetailsDto> > GetProjectMembers(Guid projectId)
        {
            var projectMembersList = await _projectManagementRepository.GetProjectMembers(projectId);

            var projectMemberDetailsList = new List <EmployeeBasicDetailsDto>();

            foreach (var projectMember in projectMembersList)
            {
                var projectMemberDetails = _mapper.Map <EmployeeBasicDetailsDto>(projectMember);
                projectMemberDetails.Id = projectMember.EmployeeId;
                if (projectMember.ProjectManager != null)
                {
                    var projectManagerDetails = new GetEmployeeListDto
                    {
                        Id   = (Guid)projectMember.ProjectManager,
                        Name = await _employeeService.GetEmployeeNameById((Guid)projectMember.ProjectManager)
                    };

                    projectMemberDetails.ProjectManagerDetails = projectManagerDetails;
                }
                if (projectMember.ProjectReportingManager != null)
                {
                    var reportingManagerDetails = new GetEmployeeListDto
                    {
                        Id   = (Guid)projectMember.ProjectReportingManager,
                        Name = await _employeeService.GetEmployeeNameById((Guid)projectMember.ProjectReportingManager)
                    };
                    projectMemberDetails.ReportingManagerDetails = reportingManagerDetails;
                }
                projectMemberDetails.Name = await _employeeService.GetEmployeeNameById(projectMember.EmployeeId);

                var employeeDetails = await _employeeRepository.GetEmployeeInformationAsync(projectMember.EmployeeId);

                if (employeeDetails != null)
                {
                    projectMemberDetails.CompanyId = employeeDetails.CompanyId;
                    var department = await _departmentDesignationService.GetDepartment(employeeDetails.DepartmentDesignationId);

                    if (department != null)
                    {
                        projectMemberDetails.Department = department.Name;
                    }
                    var designation = await _departmentDesignationService.GetDesignation(employeeDetails.DepartmentDesignationId);

                    if (designation != null)
                    {
                        projectMemberDetails.Designation = designation.Title;
                    }
                }

                projectMemberDetailsList.Add(projectMemberDetails);
            }
            return(projectMemberDetailsList);
        }
        /// <summary>
        /// this method is used to fetch employeeList
        /// </summary>
        /// <returns></returns>
        public async Task <List <GetEmployeeListDto> > GetEmployeeList()
        {
            var employeeDetailsList = await _employeeRepository.GetListOfEmployeeAsync();

            var employeeList = new List <GetEmployeeListDto>();

            foreach (var emp in employeeDetailsList)
            {
                var employee = new GetEmployeeListDto
                {
                    Id   = emp.Id,
                    Name = string.Format("{0} {1} {2}", emp.FirstName, emp.MiddleName, emp.LastName)
                };
                employeeList.Add(employee);
            }
            return(employeeList);
        }
        public async Task <List <GetEmployeeListDto> > GetProjectManagersOfProject(Guid projectId)
        {
            var result = new List <GetEmployeeListDto>();

            var listOfProjectManagers = await _projectManagementRepository.GetProjectManagers(projectId);

            foreach (var projectManager in listOfProjectManagers)
            {
                var employeeDetails = new GetEmployeeListDto()
                {
                    Name = await _employeeService.GetEmployeeNameById(projectManager),
                    Id   = projectManager
                };
                result.Add(employeeDetails);
            }
            return(result);
        }
        /// <summary>
        /// this method is used to get all project members name and id
        /// </summary>
        /// <param name="projectId"></param>
        /// <returns></returns>
        public async Task <List <GetEmployeeListDto> > GetProjectMembersList(Guid projectId)
        {
            var projectMembersList = await _projectManagementRepository.GetProjectMembers(projectId);

            var projectMemberDetailsList = new List <GetEmployeeListDto>();

            foreach (var projectMember in projectMembersList)
            {
                var projectMemberDetails = new GetEmployeeListDto
                {
                    Id   = (Guid)projectMember.EmployeeId,
                    Name = await _employeeService.GetEmployeeNameById((Guid)projectMember.EmployeeId)
                };
                projectMemberDetailsList.Add(projectMemberDetails);
            }
            return(projectMemberDetailsList);
        }
        /// <summary>
        /// this method returns all the Reportees of an employee
        /// </summary>
        /// <param name="employeeId"></param>
        /// <returns></returns>
        public async Task <List <GetEmployeeListDto> > GetAllReporteeAsync(Guid employeeId)
        {
            var reportee = await _reportingManagerRepository.GetAllReporteeAsync(employeeId);

            List <GetEmployeeListDto> reporteeDetailsList = new List <GetEmployeeListDto>();

            foreach (var r in reportee)
            {
                var empDetails = await _employeeRepository.GetEmployeeInformationAsync(r);

                var reporteeDetails = new GetEmployeeListDto
                {
                    Name = string.Format("{0} {1} {2}", empDetails.FirstName, empDetails.MiddleName, empDetails.LastName),
                    Id   = empDetails.Id
                };
                reporteeDetailsList.Add(reporteeDetails);
            }
            return(reporteeDetailsList);
        }
        /// <summary>
        /// this method is used to search for searchString in employee's name
        /// </summary>
        /// <param name="searchString"></param>
        /// <returns>List of Employee</returns>
        public async Task <List <GetEmployeeListDto> > EmployeeSearch(string searchString)
        {
            var employeeDetailsList = await _employeeRepository.EmployeeSearch(searchString);

            var employeeList = new List <GetEmployeeListDto>();

            foreach (var emp in employeeDetailsList)
            {
                var employeeName = string.Format("{0} {1} {2}", emp.FirstName, emp.MiddleName, emp.LastName);
                employeeName = String.Join(" ", employeeName.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries));

                var employee = new GetEmployeeListDto
                {
                    Id   = emp.Id,
                    Name = employeeName
                };
                employeeList.Add(employee);
            }
            return(employeeList);
        }
        /// <summary>
        /// this method will fetch all  projects in which the employee is/was
        /// </summary>
        /// <param name="employeeId"></param>
        /// <returns>returns the list of projects of employee</returns>
        public async Task <List <ProjectManagementViewDto> > GetAllProjectsOfEmployeeAsync(Guid employeeId)
        {
            var result = await _projectManagementRepository.GetAllProjectsOfEmployee(employeeId);

            var projectList = new List <ProjectManagementViewDto>();

            foreach (var p in result)
            {
                var projectDetails = await _projectRepository.GetProjectByIdAsync((Guid)p.ProjectId);

                var project = _mapper.Map <ProjectManagementViewDto>(p);
                project.ProjectName = projectDetails.Name;

                if (p.ProjectManager != null)
                {
                    var projectManagerDetails = new GetEmployeeListDto
                    {
                        Id   = (Guid)p.ProjectManager,
                        Name = await _employeeService.GetEmployeeNameById((Guid)p.ProjectManager)
                    };

                    project.ProjectManagerDetails = projectManagerDetails;
                }
                if (p.ProjectReportingManager != null)
                {
                    var reportingManagerDetails = new GetEmployeeListDto
                    {
                        Id   = (Guid)p.ProjectReportingManager,
                        Name = await _employeeService.GetEmployeeNameById((Guid)p.ProjectReportingManager)
                    };
                    project.ReportingManagerDetails = reportingManagerDetails;
                }

                projectList.Add(project);
            }
            return(projectList);
        }