private void UpdateLiteraryGenres(Project project) { if (project.LiteraryGenres == null) { project.LiteraryGenres = new List <LiteraryGenre>(); } else { project.LiteraryGenres.Clear(); } var dbGenreList = m_catalogValueRepository.GetLiteraryGenreList(); foreach (var newGenreName in m_importedRecord.ImportedProject.LiteraryGenres) { var dbGenre = dbGenreList.FirstOrDefault(x => x.Name == newGenreName); // Create new Literary Genre if (dbGenre == null) { dbGenre = new LiteraryGenre { Name = newGenreName }; m_catalogValueRepository.Create(dbGenre); dbGenreList.Add(dbGenre); } // Assign Literary Genre to project if (project.LiteraryGenres.All(x => x.Id != dbGenre.Id)) { project.LiteraryGenres.Add(dbGenre); } } }
public void UpdateLiteraryGenres(long projectId, BookData bookData) { if (bookData.LiteraryGenres == null) { return; } var dbGenreList = m_catalogValueRepository.GetLiteraryGenreList(); var project = m_metadataRepository.GetAdditionalProjectMetadata(projectId, false, false, false, true, false, false, false); foreach (var newGenreName in bookData.LiteraryGenres) { var dbGenre = dbGenreList.FirstOrDefault(x => x.Name == newGenreName); // Create new Literary Genre if (dbGenre == null) { dbGenre = new LiteraryGenre { Name = newGenreName }; m_catalogValueRepository.Create(dbGenre); dbGenreList.Add(dbGenre); } // Assign Literary Genre to project if (project.LiteraryGenres.All(x => x.Id != dbGenre.Id)) { project.LiteraryGenres.Add(dbGenre); } } m_catalogValueRepository.Update(project); }