Esempio n. 1
0
 public List<BookReviewModel> GetBooksLocalReview()
 {
     var localBooks = _repository.GetBooksLocal().ToList();
     //_repository.DeleteBookLocal(localBooks[1].ID);
     var resBooks = new List<BookReviewModel>();
     foreach (var book in localBooks)
     {
         Book curBook = new BookReviewModel(book.BookPath);
         Book.Load(ref curBook);
         resBooks.Add((BookReviewModel)curBook);
     }
     return resBooks;
 }
Esempio n. 2
0
        public BookReviewModel GetBookByLocalId(string localBookId)
        {
            var query = ParseObject.GetQuery("Book")
    .WhereEqualTo("LocalBookId", localBookId);
            var result = query.FirstOrDefaultAsync().GetAwaiter().GetResult();

            var bookResult = new BookReviewModel();
            bookResult.Position = result.Get<int>("Position");
            bookResult.Author = result.Get<string>("Author");
            bookResult.Title = result.Get<string>("Title");
            bookResult.ID = result.Get<string>("LocalBookId");
            return bookResult;
        }
Esempio n. 3
0
        public async void AddBook(BookReviewModel book)
        {
            XDocument xdoc = XDocument.Load(book.BookPath);
            Stream str = new MemoryStream();
            xdoc.Save(str);
            str.Position = 0;
            ParseFile file = new ParseFile(book.Title, str);
            await file.SaveAsync();

            ParseObject newFile = new ParseObject("BookFile");
            newFile["File"] = file;
            await newFile.SaveAsync();

            var newBook = new ParseObject("Book");
            newBook["Author"] = book.Author;
            newBook["Title"] = book.Title;
            newBook["LocalBookId"] = book.ID;
            newBook["Position"] = book.Position;
            newBook["File"] = file;
            newBook["User"] = ParseUser.CurrentUser;
            await newBook.SaveAsync();
        }
Esempio n. 4
0
        public List<BookReviewModel> GetBooksLocalReviewWithoutCurrent()
        {
            //var s = GetBooksLocalReview();
            //foreach (var t in s)
            //{
            //    _repository.DeleteBookLocal(Int32.Parse(t.ID));
            //}

            //_repository.SaveBookLocal(new BookLocal() { BookPath = "/sdcard/translyte/gg.fb2", Position = 0, IsCurrent = false });
            //_repository.SaveBookLocal(new BookLocal() { BookPath = "/sdcard/translyte/Brodyagi_Dharmy.fb2", Position = 0, IsCurrent = true });
            var localBooks = _repository.GetBooksLocal().ToList();
            var resBooks = new List<BookReviewModel>();
            foreach (var book in localBooks)
            {
                if (!book.IsCurrent)
                {
                    Book curBook = new BookReviewModel(book.BookPath);
                    Book.Load(ref curBook);
                    resBooks.Add((BookReviewModel)curBook);
                }

            }
            return resBooks;
        }
Esempio n. 5
0
 public BookReviewModel GetCurrentBook()
 {
     var localBook = _repository.GetCurrentBook();
     Book curBook = new BookReviewModel();
     if (localBook != null)
     {
         curBook.BookPath = localBook.BookPath;
         curBook.Position = localBook.Position;
         Book.Load(ref curBook);
     }
     return (BookReviewModel)curBook;
 }
Esempio n. 6
0
        public List<BookReviewModel> GetBooks()
        {
            var query = ParseObject.GetQuery("Book");

            var result = query.FindAsync().GetAwaiter().GetResult();
            var books = new List<BookReviewModel>();
            var book = new BookReviewModel();
            foreach (var res in result)
            {
                book.Position = res.Get<int>("Position");
                book.Author = res.Get<string>("Author");
                book.Title = res.Get<string>("Title");
                book.ID = res.Get<string>("LocalBookId");
                books.Add(book);
            }
            return books;
        }
Esempio n. 7
0
 void OnListItemClick(object sender, AdapterView.ItemClickEventArgs e)
 {
     var book = _books[e.Position];
     Book curBook = new BookReviewModel(book.BookPath);
     //curBook.BookPath = book.BookPath;
     Book.Load(ref curBook);
     //Book res = (BookReviewModel) curBook;
     //var intent = new Intent(this, typeof(BookView));
         string jsonModel = JsonConvert.SerializeObject(book);
        // intent.PutExtra("book", jsonModel);
         //StartActivity(intent);
         var fragment = new BookView();
         Bundle bundle = new Bundle();
         bundle.PutString("book", jsonModel);
         fragment.Arguments = bundle;
         ChangeFragment(fragment);
     TranslyteDbGateway.SetCurrentBook(curBook);
     if (curBook.ID != CurrentBook.ID)
     {
         CurrentBook = (BookReviewModel)curBook;
         _books.Clear();
         _books = TranslyteDbGateway.GetBooksLocalReviewWithoutCurrent();
     }
 }