示例#1
0
        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);
        }
示例#2
0
        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 virtual BookVersion GetBookVersionDetailByBookId(long bookId)
        {
            using (var session = GetSession())
            {
                Book             bookAlias             = null;
                BookVersion      bookVersionAlias      = null;
                Responsible      responsibleAlias      = null;
                ResponsibleType  responsibleTypeAlias  = null;
                LiteraryOriginal literaryOriginalAlias = null;
                LiteraryKind     literaryKindAlias     = null;
                LiteraryGenre    genreAlias            = null;

                var query = session.QueryOver(() => bookVersionAlias)
                            .JoinAlias(x => x.Book, () => bookAlias)
                            .Where(() => bookAlias.LastVersion.Id == bookVersionAlias.Id)
                            .And(x => bookAlias.Id == bookId);

                var futureResult = query
                                   .Fetch(x => x.Book).Eager
                                   .Fetch(x => x.Publisher).Eager
                                   .Fetch(x => x.DefaultBookType).Eager
                                   .FutureValue <BookVersion>();

                session.QueryOver(() => bookVersionAlias)
                .JoinAlias(x => x.Book, () => bookAlias)
                .Where(() => bookAlias.LastVersion.Id == bookVersionAlias.Id)
                .And(x => bookAlias.Id == bookId)
                .Fetch(x => x.ManuscriptDescriptions).Eager
                .FutureValue <BookVersion>();

                session.QueryOver(() => bookVersionAlias)
                .JoinAlias(x => x.Book, () => bookAlias)
                .Where(() => bookAlias.LastVersion.Id == bookVersionAlias.Id)
                .And(x => bookAlias.Id == bookId)
                .Fetch(x => x.Authors).Eager
                .FutureValue <BookVersion>();

                session.QueryOver(() => bookVersionAlias)
                .JoinAlias(x => x.Book, () => bookAlias)
                .Where(() => bookAlias.LastVersion.Id == bookVersionAlias.Id)
                .And(x => bookAlias.Id == bookId)
                .Fetch(x => x.Keywords).Eager
                .FutureValue <BookVersion>();

                session.QueryOver(() => bookVersionAlias)
                .JoinAlias(x => x.Book, () => bookAlias)
                .Where(() => bookAlias.LastVersion.Id == bookVersionAlias.Id)
                .And(x => bookAlias.Id == bookId)
                .Fetch(x => x.FullBookRecordings).Eager
                .FutureValue <BookVersion>();

                session.QueryOver(() => bookVersionAlias)
                .JoinAlias(x => x.Book, () => bookAlias)
                .Where(() => bookAlias.LastVersion.Id == bookVersionAlias.Id)
                .And(x => bookAlias.Id == bookId)
                .Left.JoinAlias(() => bookVersionAlias.Responsibles, () => responsibleAlias)
                .Left.JoinAlias(() => responsibleAlias.ResponsibleType, () => responsibleTypeAlias)
                .FutureValue <BookVersion>();

                session.QueryOver(() => bookVersionAlias)
                .JoinAlias(x => x.Book, () => bookAlias)
                .Where(() => bookAlias.LastVersion.Id == bookVersionAlias.Id)
                .And(x => bookAlias.Id == bookId)
                .Left.JoinAlias(() => bookVersionAlias.LiteraryOriginals, () => literaryOriginalAlias)
                .Fetch(x => x.LiteraryOriginals).Eager
                .FutureValue <BookVersion>();

                session.QueryOver(() => bookVersionAlias)
                .JoinAlias(x => x.Book, () => bookAlias)
                .Where(() => bookAlias.LastVersion.Id == bookVersionAlias.Id)
                .And(x => bookAlias.Id == bookId)
                .Left.JoinAlias(() => bookVersionAlias.LiteraryKinds, () => literaryKindAlias)
                .Fetch(x => x.LiteraryKinds).Eager
                .FutureValue <BookVersion>();

                session.QueryOver(() => bookVersionAlias)
                .JoinAlias(x => x.Book, () => bookAlias)
                .Where(() => bookAlias.LastVersion.Id == bookVersionAlias.Id)
                .And(x => bookAlias.Id == bookId)
                .Left.JoinAlias(() => bookVersionAlias.LiteraryGenres, () => genreAlias)
                .Fetch(x => x.LiteraryGenres).Eager
                .FutureValue <BookVersion>();

                var result = futureResult.Value;
                return(result);
            }
        }