public void SetBookItem(Book newDetailItem) { if (newBook != newDetailItem) { newBook = newDetailItem; // attempt to set it manually newBook.title = newDetailItem.getTitle (); newBook.author = newDetailItem.getAuthor (); newBook.publisher = newDetailItem.getPublisher (); newBook.summary = newDetailItem.getSummary (); newBook.isbn = newDetailItem.getIsbn (); newBook.dateadded = newDetailItem.getDateAdded (); timeAdded = newDetailItem.getDateAdded (); Console.Out.WriteLine ("Time added: " + timeAdded.ToString ()); Console.Out.WriteLine ("Set Book Item entered: " + newBook.getTitle ()); } }
async void scanIsbn() { // start the barcode scanner var scanner = new ZXing.Mobile.MobileBarcodeScanner(); var result = await scanner.Scan(); try { // create an object to hold the book. Book newBook = new Book (result.Text); Console.Out.WriteLine ("newbook title: " + newBook.getTitle ()); // make sure it's actually a book before adding it. try { if (newBook.getAuthor().Length > 3) { insertToDatabase (newBook); Console.Out.WriteLine("newbook added"); dataSource.Objects.Insert (0, newBook); using (var indexPath = NSIndexPath.FromRowSection (0, 0)) TableView.InsertRows (new [] { indexPath }, UITableViewRowAnimation.Automatic); } else Console.Out.WriteLine ("newbook seems to be null"); } catch(Exception ex) { Console.Out.WriteLine ("Adding newbook error: " + ex.ToString ()); } } catch(Exception ex) { Console.Out.WriteLine ("scanning was probably canceled.\n" + ex.ToString ()); } }