private async void postClicked(object sender, EventArgs e) { string FileName = generate.generateFileKey(); IFolder folder = FileSystem.Current.LocalStorage; // post a new book if (bookName.Text != null && bookType.Text != null && mediaFile != null)//conditons all fields need to be filled { IFile file = await folder.CreateFileAsync(FileName, CreationCollisionOption.FailIfExists); string content = description.Text; await file.WriteAllTextAsync(content); BookDetail aBookInfo = new BookDetail(); aBookInfo.booksName = bookName.Text; aBookInfo.booksType = bookType.Text; aBookInfo.description = description.Text; aBookInfo.ownersID = currentID; aBookInfo.getDescriptionFile = FileName; aBookInfo.booksCover = mediaFile.Path; App.databaseBook.saveBook(aBookInfo); await Navigation.PopModalAsync(); await DisplayAlert("", "post successfully", "ok"); } else { await DisplayAlert("", "enter all fields", "ok"); } }
public void setData(BookDetail book) //fecth the data for the seletced book { thisBook = book; loadBookCover.Source = thisBook.booksCover; name.Text = thisBook.booksName; type.Text = thisBook.booksType; getDescription.Text = thisBook.description; view.Text = thisBook.booksViewed.ToString(); borrow.Text = thisBook.booksLended.ToString(); }
//save or update public int saveBook(BookDetail book) { if (book.ID > 0) { return(bDatabase.Update(book)); } else { return(bDatabase.Insert(book)); } }
public void SetData(BookDetail book) //fetch the book data { SelectedBook = book; images.Source = SelectedBook.booksCover; name.Text = SelectedBook.booksName; type.Text = SelectedBook.booksType; oname.Text = App.Database.getCurrentUserName(SelectedBook.ownersID); description.Text = SelectedBook.description; viewTimes.Text = SelectedBook.booksViewed.ToString(); lendedTime.Text = SelectedBook.booksLended.ToString(); }
private async void booksLendedSelected(object sender, SelectedItemChangedEventArgs e) { if (e.SelectedItem == null) { return; } BookDetail selectedBook = e.SelectedItem as BookDetail; booksBeBorrowed.setData(selectedBook); await Navigation.PushModalAsync(booksBeBorrowed, true); ((ListView)sender).SelectedItem = null; // de-select the row }
public void setData(BookDetail book) //get the selected book details { selectedBook = book; images.Source = selectedBook.booksCover; bName.Text = selectedBook.booksName; bType.Text = selectedBook.booksType; bookDescription.Text = selectedBook.description; viewTime.Text = selectedBook.booksViewed.ToString(); borrow.Text = selectedBook.booksLended.ToString(); bOwner.Text = App.Database.getCurrentUserName(selectedBook.ownersID); startD.Text = selectedBook.getBrorrowedDate; endD.Text = selectedBook.getReturnedDate; }
public void setData(BookDetail book)//get the book detials { bookBeingBorrowed = book; images.Source = bookBeingBorrowed.booksCover; name.Text = bookBeingBorrowed.booksName; type.Text = bookBeingBorrowed.booksType; Bername.Text = App.Database.getCurrentUserName(Convert.ToInt32(bookBeingBorrowed.borrowersID)); email.Text = App.Database.getCurrentUserNameEmail(Convert.ToInt32(bookBeingBorrowed.borrowersID)); view.Text = bookBeingBorrowed.booksViewed.ToString(); borrow.Text = bookBeingBorrowed.booksLended.ToString(); getDescription.Text = bookBeingBorrowed.description; startDate.Text = bookBeingBorrowed.getBrorrowedDate.ToString(); returnDate.Text = bookBeingBorrowed.getReturnedDate.ToString(); }
private async void bookSelected(object sender, SelectedItemChangedEventArgs e) //select the book for borrowing { if (e.SelectedItem == null) { return; } BookDetail selectedBook = e.SelectedItem as BookDetail; selectedBook.booksViewed = selectedBook.booksViewed + 1; App.databaseBook.saveBook(selectedBook); bb.SetData(selectedBook); await Navigation.PushModalAsync(bb, true); ((ListView)sender).SelectedItem = null; // de-select the row }
public modifyYourBookPage(BookDetail book) { thisBook = book; InitializeComponent(); }
//delete public int deleteBook(BookDetail book) { return(bDatabase.Delete(book)); }
public viewBorrowedBook(BookDetail book) { selectedBook = book; InitializeComponent(); }
public viewLendedBook(BookDetail book) { bookBeingBorrowed = book; InitializeComponent(); }
public borrowBook(BookDetail book)//constructor take book as argument { SelectedBook = book; InitializeComponent(); }