Esempio n. 1
0
        public List <Models.GetOwnedBook> getOwnedBooks()
        {
            List <Models.GetOwnedBook> books = new List <Models.GetOwnedBook>();

            string[] lines = System.IO.File.ReadAllLines(strOwnedBooksBase);
            foreach (string line in lines)
            {
                try
                {
                    Models.OwnedBook book = Newtonsoft.Json.JsonConvert.DeserializeObject <Models.OwnedBook>(line);
                    if (book.Id > lastId)
                    {
                        lastId = book.Id;
                    }
                    Models.GetOwnedBook retBook = new Models.GetOwnedBook();
                    retBook.Aquired  = book.Aquired;
                    retBook.BookId   = book.BookId;
                    retBook.Id       = book.Id;
                    retBook.UserId   = book.UserId;
                    retBook.Favorite = book.Favorite;
                    retBook.cBook    = new BookDbHelper().getBook(retBook.BookId);
                    books.Add(retBook);
                }
                catch (Exception ex)
                {
                    MainWindow.showError(ex.Message);
                }
            }
            return(books);
        }
Esempio n. 2
0
        public Models.OwnedBook getOwnedBook(int nId)
        {
            List <Models.OwnedBook> books = getOwnedBook();

            for (var enu = books.GetEnumerator(); enu.MoveNext();)
            {
                if (enu.Current.Id == nId)
                {
                    Models.GetOwnedBook retBook = new Models.GetOwnedBook();
                    retBook.Aquired  = enu.Current.Aquired;
                    retBook.BookId   = enu.Current.BookId;
                    retBook.Id       = enu.Current.Id;
                    retBook.UserId   = enu.Current.UserId;
                    retBook.Favorite = enu.Current.Favorite;
                    retBook.cBook    = new BookDbHelper().getBook(retBook.BookId);
                    return(retBook);
                }
            }
            return(null);
        }