Exemple #1
0
        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);
        }
Exemple #2
0
        protected override void ExecuteWorkImplementation()
        {
            if (m_importedRecord.IsNew)
            {
                m_importedRecord.ProjectId = CreateProject();
                m_importedRecord.ImportedProjectMetadataId = CreateImportedProjectMetadata();
            }

            m_projectId = m_importedRecord.ProjectId;
            var project = m_metadataRepository.GetAdditionalProjectMetadata(m_projectId, true, false, false, true, true, true, false);

            UpdateLiteraryGenres(project);
            UpdateLiteraryOriginals(project);
            UpdateKeywords(project);
            UpdateAuthors(project);
            UpdateMetadata(project);

            m_catalogValueRepository.Update(project);

            CreateSnapshot();
            ProcessExternalImportPermission();
            m_projectRepository.UnitOfWork.CurrentSession.Flush();
            m_projectRepository.UnitOfWork.CurrentSession.Evict(project); //because of unit tests - unit test is running in one session
        }