Ejemplo n.º 1
0
        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");
            }
        }
Ejemplo n.º 2
0
 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));
     }
 }
Ejemplo n.º 4
0
 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();
 }
Ejemplo n.º 5
0
        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
        }
Ejemplo n.º 6
0
 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();
 }
Ejemplo n.º 8
0
        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
        }
Ejemplo n.º 9
0
 public modifyYourBookPage(BookDetail book)
 {
     thisBook = book;
     InitializeComponent();
 }
 //delete
 public int deleteBook(BookDetail book)
 {
     return(bDatabase.Delete(book));
 }
Ejemplo n.º 11
0
 public viewBorrowedBook(BookDetail book)
 {
     selectedBook = book;
     InitializeComponent();
 }
 public viewLendedBook(BookDetail book)
 {
     bookBeingBorrowed = book;
     InitializeComponent();
 }
Ejemplo n.º 13
0
 public borrowBook(BookDetail book)//constructor take book as argument
 {
     SelectedBook = book;
     InitializeComponent();
 }