Example #1
0
        private static BookModel CreateBook(Book item, BookSummary bookSummary)
        {
            var trial = !(item.IsFreeBook || item.IsMyBook);
            var book = new BookModel
            {
                BookID = item.Id.ToString(),
                Title = bookSummary.Title.SafeSubstring(1024),
                Author = bookSummary.AuthorName.SafeSubstring(1024),
                Type = item.Type,
                Hidden = trial,
                Trial = trial,
                Deleted = false,
                CreatedDate = DateTime.Now.ToFileTimeUtc(),
                UniqueID = bookSummary.UniqueId.SafeSubstring(1024),
                Description = bookSummary.Description,
                Language = bookSummary.Language,
                Url = item.Url,
               // CatalogItemId = item.CatalogItemId
            };

            return book;
        }
Example #2
0
        private void SaveBook(Book item, BookSummary bookSummary, IBookSummaryParser previewGenerator, IsolatedStorageFile storeForApplication)
        {
            var bookFolder = item.IsMyBook || item.IsFreeBook ? item.Id.ToString() : item.Id + ".trial";
            using (var imageStorageFileStream = new IsolatedStorageFileStream(CreateImagesPath(bookFolder), FileMode.Create, storeForApplication))
            {
                previewGenerator.SaveImages(imageStorageFileStream);
            }

           // previewGenerator.SaveCover(item.BookID.ToString());

            var book = CreateBook(item, bookSummary);

            try
            {
                //_dataCacheService.PutItem(book, book.BookID, CancellationToken.None);
                TokensTool.SaveTokens(book, previewGenerator);
                book.Hidden = book.Trial;
               // _bookService.Save(book);                
            }
            catch (Exception)
            {
                //_bookService.Remove(book.BookID);
                throw;
            }
            ReplaceBookInSettings(book);
        }