Example #1
0
        private bool IndexEBook(BookViewModel bookViewModel, string path)
        {
            bool     success;
            Document document = null;

            string      language = LanguageService.Get(bookViewModel.LanguageId).Name;
            IndexerType type     = AnalyzerService.GetIndexerType(language);

            BookDomainModelBuilder builder = BuilderResolverService.Get <BookDomainModelBuilder, BookViewModel>(bookViewModel);

            Constructor.ConstructDomainModelData(builder);
            BookData book = builder.GetDataModel();

            try
            {
                document = DocumentHandler.GetDocument(book, path);
                if (book.Id != 0)
                {
                    EBookIndexer.DeleteById(book.Id.ToString(), type);
                }

                EBookIndexer.Add(document, type);
                success = true;
            }
            catch (Exception e)
            {
                success = false;
            }

            return(success);
        }
Example #2
0
        public SaveBookResult Save(BookViewModel viewModel, UserSessionObject user)
        {
            var result = new SaveBookResult();

            BookDomainModelBuilder builder = BuilderResolverService.Get <BookDomainModelBuilder, BookViewModel>(viewModel);

            Constructor.ConstructDomainModelData(builder);
            BookData domainModel = builder.GetDataModel();

            if (viewModel.Id == 0)
            {
                domainModel.RefUserCreatedBy = user.UserId;
            }

            int id = BookRepository.SaveData(domainModel);

            if (id != 0)
            {
                result = new SaveBookResult(id, domainModel.BookAuthorAndTitle);
            }

            return(result);
        }