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); } } }
public void UpdateLiteraryKinds(long projectId, BookData bookData) { if (bookData.LiteraryKinds == null) { return; } var dbKindList = m_catalogValueRepository.GetLiteraryKindList(); var project = m_metadataRepository.GetAdditionalProjectMetadata(projectId, false, false, true, false, false, false, false); foreach (var newKindName in bookData.LiteraryKinds) { var dbKind = dbKindList.FirstOrDefault(x => x.Name == newKindName); // Create new Literary Kind if (dbKind == null) { dbKind = new LiteraryKind { Name = newKindName }; m_catalogValueRepository.Create(dbKind); dbKindList.Add(dbKind); } // Assign Literary Kind to project if (project.LiteraryKinds.All(x => x.Id != dbKind.Id)) { project.LiteraryKinds.Add(dbKind); } } m_catalogValueRepository.Update(project); }