/// <summary> /// Initializes a new instance of the <see cref="RemoveBookViewModel"/> class. /// </summary> /// <param name="view"> /// The view. /// </param> /// <param name="eventAggregator"> /// The event aggregator. /// </param> /// <exception cref="Exception"> /// </exception> public RemoveBookViewModel(IView view, IEventAggregator eventAggregator) { try { this._eventAggregator = eventAggregator; this.View = view; this.bookManager = new BookManager(); this.books = new ObservableCollection<Book>(this.bookManager.GetAllBooks()); AvailableBooksEvent updatedAvailableBooksEvent = _eventAggregator.GetEvent<AvailableBooksEvent>(); subscriptionTokenForAvailableBooks = updatedAvailableBooksEvent.Subscribe( UpdateAvailableBooksEventHandler, ThreadOption.UIThread, false, (updatedBooks) => true); CreateBookEvent bookAddedEvent = _eventAggregator.GetEvent<CreateBookEvent>(); subscriptionTokenForAddBook = bookAddedEvent.Subscribe( AddNewBookEventHandler, ThreadOption.UIThread, false, (book) => true); } catch (Exception exception) { throw exception; } }
/// <summary> /// Initializes a new instance of the <see cref="SearchBookViewModel"/> class. /// </summary> public SearchBookViewModel() { this.BookManager = new BookManager(); searchCriteriaCollection = new List<string>(); this.searchCriteriaCollection.Add("all"); this.searchCriteriaCollection.Add("title"); this.searchCriteriaCollection.Add("author"); this.searchCriteriaCollection.Add("category"); }
/// <summary> /// Initializes a new instance of the <see cref="ReturnBookViewModel"/> class. /// </summary> /// <param name="view"> /// The view. /// </param> /// <param name="eventAggregator"> /// The event Aggregator. /// </param> /// <exception cref="Exception"> /// </exception> public ReturnBookViewModel(IView view, IEventAggregator eventAggregator) { try { this.View = view; this.bookManager = new BookManager(); this._eventAggregator = eventAggregator; this.booksBorrowedByUser = new ObservableCollection<Book>(this.bookManager.GetBooksIssuedByUserID()); BorrowBooksEvent updatedBorrowedBooks = eventAggregator.GetEvent<BorrowBooksEvent>(); subscriptionToken = updatedBorrowedBooks.Subscribe( UpdatedBorrowBooksEventHandler, ThreadOption.UIThread, false, (updatedBooks) => true); } catch (Exception exception) { throw exception; } }
/// <summary> /// Initializes a new instance of the <see cref="AddBookViewModel"/> class. /// </summary> /// <param name="view"> /// The view. /// </param> /// <param name="eventAggregator"> /// The event Aggregator. /// </param> /// <exception cref="Exception"> /// </exception> public AddBookViewModel(IView view, IEventAggregator eventAggregator) { try { this.View = view; this._eventAggregator = eventAggregator; this.categoryManager = new CategoryManager(); this.bookManager = new BookManager(); this._allCategories = new ObservableCollection<Category>(this.categoryManager.GetAllCategories()); CreateCategoryEvent categoryAddedEvent = eventAggregator.GetEvent<CreateCategoryEvent>(); this.subscriptionToken = categoryAddedEvent.Subscribe( this.AddNewCategoryEventHandler, ThreadOption.UIThread, false, (category) => true); } catch (Exception exception) { throw exception; } }