private async Task <ElasticEmployeeDetails> AddEmployeeToElasticSearch(ElasticEmployeeDetailsDto elasticEmployeeDetailsDto) { var employeeName = string.Format("{0} {1} {2}", elasticEmployeeDetailsDto.FirstName, elasticEmployeeDetailsDto.MiddleName, elasticEmployeeDetailsDto.LastName); employeeName = String.Join(" ", employeeName.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries)); var department = await _departmentDesignationRepository.GetDepartmentById(elasticEmployeeDetailsDto.DepartmentId); var designation = await _departmentDesignationRepository.GetDesignationById(elasticEmployeeDetailsDto.DesignationId); var skills = new List <string>(); skills.Union(elasticEmployeeDetailsDto.PrimarySkill); skills.Union(elasticEmployeeDetailsDto.SecondarySkill); var elasticEmployeeDetails = new ElasticEmployeeDetails { Id = elasticEmployeeDetailsDto.Id, Name = employeeName, DepartmentName = department.Name, DesignationName = designation.Title, CompanyId = elasticEmployeeDetailsDto.CompanyId, CompanyEmail = elasticEmployeeDetailsDto.CompanyEmail, Skills = skills }; await _elasticSearchService.AddUserToElasticSearch(elasticEmployeeDetails); return(elasticEmployeeDetails); }
public async Task <bool> AddUserToElasticSearch(ElasticEmployeeDetails employee) { await CreateIndex(); var result = await _client.IndexDocumentAsync(employee); if (result.IsValid) { return(true); } return(false); }
public async Task <ActionResult <bool> > AddEmployeeToElasticSearch([FromBody] ElasticEmployeeDetails employee) { var result = await _elasticSearchService.AddUserToElasticSearch(employee); return(result); }