Пример #1
0
        private void UpdateLiteraryOriginals(Project project)
        {
            if (project.LiteraryOriginals == null)
            {
                project.LiteraryOriginals = new List <LiteraryOriginal>();
            }
            else
            {
                project.LiteraryOriginals.Clear();
            }

            var dbOriginalList = m_catalogValueRepository.GetLiteraryOriginalList();

            foreach (var newOriginalName in m_importedRecord.ImportedProject.LiteraryOriginals)
            {
                var dbOriginal = dbOriginalList.FirstOrDefault(x => x.Name == newOriginalName);

                // Create new Literary Original
                if (dbOriginal == null)
                {
                    dbOriginal = new LiteraryOriginal
                    {
                        Name = newOriginalName
                    };
                    m_catalogValueRepository.Create(dbOriginal);
                    dbOriginalList.Add(dbOriginal);
                }

                // Assign Literary Original to project
                if (project.LiteraryOriginals.All(x => x.Id != dbOriginal.Id))
                {
                    project.LiteraryOriginals.Add(dbOriginal);
                }
            }
        }
        public void UpdateLiteraryOriginals(long projectId, BookData bookData)
        {
            if (bookData.LiteraryOriginals == null)
            {
                return;
            }

            var dbOriginalList = m_catalogValueRepository.GetLiteraryOriginalList();
            var project        = m_metadataRepository.GetAdditionalProjectMetadata(projectId, false, false, false, false, true, false, false);

            foreach (var newOriginalName in bookData.LiteraryOriginals)
            {
                var dbOriginal = dbOriginalList.FirstOrDefault(x => x.Name == newOriginalName);

                // Create new Literary Original
                if (dbOriginal == null)
                {
                    dbOriginal = new LiteraryOriginal
                    {
                        Name = newOriginalName
                    };
                    m_catalogValueRepository.Create(dbOriginal);
                    dbOriginalList.Add(dbOriginal);
                }

                // Assign Literary Original to project
                if (project.LiteraryOriginals.All(x => x.Id != dbOriginal.Id))
                {
                    project.LiteraryOriginals.Add(dbOriginal);
                }
            }
            m_catalogValueRepository.Update(project);
        }