/// <summary> /// Initializes a new instance of the <see cref="CreateCategoryViewModel"/> class. /// </summary> /// <param name="View"> /// The view. /// </param> /// <param name="eventAggregator"> /// The Event Aggregator /// </param> /// <exception cref="Exception"> /// </exception> public CreateCategoryViewModel(IView View, IEventAggregator eventAggregator) { try { this._view = View; this._eventAggregator = eventAggregator; this._categoryManager = new CategoryManager(); this._allCategories = new ObservableCollection<Category>(_categoryManager.GetAllCategories()); } 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; } }