Beispiel #1
0
 public void Display(EditDetails parentForm, IBookCollection bookCollection)
 {
     this.parentForm       = parentForm;
     this.bookCollection   = bookCollection;
     availableBooks.Source = GetAvailableBooks( );
     Visibility            = Visibility.Visible;
 }
 public BookController(
     IBookCollection database,
     ILogger <BookController> logger)
 {
     _database = database;
     _logger   = logger;
 }
Beispiel #3
0
        private void LoadBooksForAttribute(object sender, RoutedEventArgs e)
        {
            if (sender == null || !(sender is Hyperlink))
            {
                return;
            }
            IBookCollection bookHolder = ((sender as Hyperlink).CommandParameter) as IBookCollection;

            if (bookHolder == null)
            {
                return;
            }

            bool alreadyDisplaying = isAlreadyDisplaying(bookHolder);

            if (alreadyDisplaying)
            {
                System.Media.SystemSounds.Exclamation.Play( );
            }

            statusMessage = (alreadyDisplaying ? "Already displaying" : "Displaying") + " books for " + bookHolder.Name;
            DisplayBooks(bookHolder.Books);
            viewingBooksForAttribute = bookHolder;
            e.Handled = true;
        }
Beispiel #4
0
        private void ResetDisplay( )
        {
            viewingBooksForAttribute = null;
            AuthorButton.IsEnabled   = true;
            BookButton.IsEnabled     = true;
            CategoryButton.IsEnabled = true;

            if (statusMessage == null)
            {
                if (currentView == ItemType.Author)
                {
                    statusMessage = "Displaying Authors";
                }
                if (currentView == ItemType.Book)
                {
                    statusMessage = "Displaying Books";
                }
                if (currentView == ItemType.Category)
                {
                    statusMessage = "Displaying Categories";
                }
            }

            StatusText.Content = statusMessage;
            statusMessage      = null;
        }
Beispiel #5
0
 private bool isAlreadyDisplaying(IBookCollection bookHolder)
 {
     if (viewingBooksForAttribute == null)
     {
         return(false);
     }
     return(bookHolder == viewingBooksForAttribute);
 }
Beispiel #6
0
 public void SeeBooks(IBookCollection library, IBookIterator iterator)
 {
     for (Book item = iterator.First(); !iterator.IsDone; item = iterator.Next())
     {
         Console.WriteLine(iterator.CurrentItem.Name);
         item.Print();
     }
 }
 public static IBookCollection Synchronized(IBookCollection acc)
 {
     if (acc == null)
     {
         throw  new ArgumentNullException("acc");
     }
     if (acc.GetType() == typeof(SyncBookLib))
     {
         throw new InvalidOperationException("Booklib reference is already synchronized.");
     }
     return(new SyncBookLib(acc));
 }
         private bool BookMatchExists(string isbn)
         {
             bool returnValue = false;
 
             IBookCollection coll = MyCompany.Applications.MyApplication.BusinessLogic.CachedControllers.BookController.FindAll(); /* Code not shown, but this would hit the db and return poco objects of books*/
 
             IBook foundBook = (from item in coll where item.ISBN.Equals(book, StringComparison.OrdinalIgnoreCase) select item).SingleOrDefault();
 
             if (null != foundBook)
             {
                 returnValue = true;
             }
             return returnValue;
         }
Beispiel #9
0
        public virtual IBookIterator Create(IBookCollection collection, BookIteratorType type)
        {
            IBookIterator iterator = null;

            switch (type)
            {
            case BookIteratorType.normal:
                iterator = new LibraryIterator(collection);
                break;

            case BookIteratorType.reverse:
                iterator = new LibraryReverseIterator(collection);
                break;

            default:
                iterator = new LibraryIterator(collection);
                break;
            }

            return(iterator);
        }
Beispiel #10
0
        private void OnUpdate(bool commitUpdate)
        {
            if (!commitUpdate)
            {
                statusMessage += "Update canceled";
            }

            switch (currentView)
            {
            case ItemType.Author:
                DisplayAllAuthors( );
                break;

            case ItemType.Category:
                DisplayAllCategories( );
                break;

            case ItemType.Book:
            default:
                if (viewingBooksForAttribute != null)
                {
                    // refresh this item from the datacontext
                    viewingBooksForAttribute = Catalog.GetExistingItem(viewingBooksForAttribute) as IBookCollection;
                }

                if (viewingBooksForAttribute != null)
                {
                    DisplayBooks(viewingBooksForAttribute.Books);
                }
                else
                {
                    DisplayAllBooks( );
                }
                break;
            }
        }
Beispiel #11
0
 internal SyncBookLib(IBookCollection acc)
 {
     booklib  = acc;
     syncRoot = acc.SyncRoot;
 }
Beispiel #12
0
 public LibraryReverseIterator(IBookCollection collection)
 {
     _collection = collection;
 }