public void UpdateKeywords(long projectId, BookData bookData) { if (bookData.Keywords == null) { return; } var project = m_projectRepository.GetProjectWithKeywords(projectId); foreach (var newKeywordName in bookData.Keywords) { var dbKeyword = m_catalogValueRepository.GetKeywordByName(newKeywordName); // Create new Keyword if (dbKeyword == null) { dbKeyword = new Keyword { Text = newKeywordName }; project.Keywords.Add(dbKeyword); } // Assign existing Keyword to project else if (project.Keywords.All(x => x.Id != dbKeyword.Id)) { project.Keywords.Add(dbKeyword); } } m_projectRepository.Update(project); }
private void UpdateKeywords(Project project) { if (project.Keywords == null) { project.Keywords = new List <Keyword>(); } else { project.Keywords.Clear(); } foreach (var newKeywordName in m_importedRecord.ImportedProject.Keywords) { var dbKeyword = m_catalogValueRepository.GetKeywordByName(newKeywordName); // Create new Keyword if (dbKeyword == null) { dbKeyword = new Keyword { Text = newKeywordName }; m_catalogValueRepository.Create(dbKeyword); } // Assign existing Keyword to project if (project.Keywords.All(x => x.Id != dbKeyword.Id)) { project.Keywords.Add(dbKeyword); } } }