public Book GetBook(Book book) { Book rs = new Book(); using (var db = new SQLiteConnection(this.Path, this.State)) { rs = db.Query<Book>("SELECT * FROM BOOK WHERE ID=?", book.Id).Single(); } return rs; }
public ObservableCollection<Book> GetBooksOfTactic(Book book) { using (var db = new SQLiteConnection(this.Path, this.State)) { var r = db.Query<Book>("SELECT * FROM BOOK WHERE TACTICID=?", book.TacticID); this.Books = new ObservableCollection<Book>(r); } return this.Books; }
public int InsertBook(Book book) { int rs = -1; using (var db = new SQLiteConnection(this.Path, this.State)) { db.RunInTransaction(() => { rs = db.Insert(book); }); } return rs; }
public int UpdateBook(Book book) { int rs = -1; using (var db = new SQLiteConnection(this.Path, this.State)) { var existing = db.Query<Book>("SELECT * FROM BOOK WHERE ID=?", book.Id).FirstOrDefault(); if (existing != null) { existing = book.GetCopy(); db.RunInTransaction(() => { rs = db.Update(existing); }); this.RaisePropertyChanged("Books"); // Notify changed to update view } } return rs; }
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e) { base.OnNavigatedTo(e); this.book = (Book)PhoneApplicationService.Current.State["selectedBook"]; this.lessons = viewModelLesson.GetLessonOfBooks(new Lesson() { BookID = this.book.Id }); txbPagename.Text = book.Name; if (this.book.TacticID == 1) txbCollection.Text = "OPENINGS"; else if (this.book.TacticID == 2) txbCollection.Text = "MID GAMES"; else if (this.book.TacticID == 3) txbCollection.Text = "END GAMES"; else if (this.book.TacticID == 4) txbCollection.Text = "TOURNAMENTS"; // insert into Lesson (BookID, Name, Png, CountStarsPassed, CountStarsRequire, CountPractises, IsCompleted) //values (2, 'Binh Phong Ma', '123456', 0, 5, 0, 0) }