Exemple #1
0
        /* Renting books */
        #region
        private void RentBookButton_Click(object sender, RoutedEventArgs e)
        {
            object selection = DataContextContainer.SelectedItem;

            if (selection != null)
            {
                Book book = (Book)selection;

                if (book.State != BookState.Available)
                {
                    /* Error */
                    if (rentResultWindow == null || !rentResultWindow.IsLoaded)
                    {
                        rentResultWindow = new RentResultWindow(RentResultType.CannotBorrow);
                        rentResultWindow.Show();
                    }
                }
                else
                {
                    /* Try to rent the book */
                    if (bookRentingWindow == null || !bookRentingWindow.IsLoaded)
                    {
                        bookRentingWindow = new BookRentingWindow(libService, book, RentReturn);
                        bookRentingWindow.Show();
                    }
                }
            }
        }
Exemple #2
0
        public void RentReturn(bool success)
        {
            ShowList();

            if (success)
            {
                /* Success */
                if (rentResultWindow == null || !rentResultWindow.IsLoaded)
                {
                    rentResultWindow = new RentResultWindow(RentResultType.RentSuccess);
                    rentResultWindow.Show();
                }
            }
            else
            {
                /* Failure */
                if (rentResultWindow == null || !rentResultWindow.IsLoaded)
                {
                    rentResultWindow = new RentResultWindow(RentResultType.UserNotFound);
                    rentResultWindow.Show();
                }
            }
        }