예제 #1
0
        public AddBookPresenter(IBookService bookService, ITagService tagService, IAuthorService authorService, IPublisherService publisherService,
                                IAddBookForm view,
                                IImageFileReader imageFileReader)
        {
            this._bookService      = bookService;
            this._tagService       = tagService;
            this._authorService    = authorService;
            this._publisherService = publisherService;

            this._view = view;

            this._imageFileReader = imageFileReader;

            this._allTags       = new Dictionary <string, bool>();
            this._allAuthors    = new Dictionary <string, bool>();
            this._allPublishers = new List <string>();

            // subscribe to the view's events
            this._view.SaveButtonClicked += (async(sender, args) =>
            {
                await HandleSaveButtonClicked(sender, args);
            });
            this._view.InputFieldsUpdated           += InputFieldsUpdated;
            this._view.FilterTagsFieldUpdated       += FilterTags;
            this._view.FilterAuthorsFieldUpdated    += FilterAuthors;
            this._view.FilterPublishersFieldUpdated += FilterPublishers;
            this._view.AddNewTagButtonClicked       += HandleAddNewTagClicked;
            this._view.AddNewAuthorButtonClicked    += HandleAddNewAuthorClicked;
            this._view.AddNewPublisherButtonClicked += HandleAddNewPublisherClicked;
            this._view.TagCheckedChanged            += HandleTagCheckedChanged;
            this._view.AuthorCheckedChanged         += HandleAuthorCheckedChanged;
        }
예제 #2
0
        public void SearchByIsbnClicked(object sender, EventArgs e)
        {
            SearchByIsbnDialog searchDialog = new SearchByIsbnDialog();

            this._addBookView = new AddNewBookForm();
            var searchPresenter = new SearchByIsbnPresenter(searchDialog, this._addBookView, new BookService(), new ApiServiceProvider());

            searchPresenter.AddBookPresenter = new AddBookPresenter(this._bookService, this._tagService, this._authorService, this._publisherService,
                                                                    this._addBookView, new ImageFileReader());
            searchDialog.ShowDialog();

            ItemsAdded(null, null);
        }
예제 #3
0
        public async void AddNewBookClicked(object sender, EventArgs e)
        {
            this._addBookView = new AddNewBookForm();
            var addBookPresenter = new AddBookPresenter(this._bookService, this._tagService, this._authorService, this._publisherService,
                                                        this._addBookView, new ImageFileReader());
            await addBookPresenter.PopulateTagsList();

            await addBookPresenter.PopulateAuthorsList();

            await addBookPresenter.PopulatePublishersList();

            this._addBookView.ItemAdded += ItemsAdded;
            ((AddNewBookForm)this._addBookView).ShowDialog();
        }
예제 #4
0
        /// <summary>
        /// Constructor with dependency injection.
        /// </summary>
        /// <param name="view"></param>
        public SearchByIsbnPresenter(ISearchByIsbn view, IAddBookForm addBookView, IBookService bookService, IApiServiceProvider apiServiceProvider)
        {
            // inject values
            this._view               = view;
            this._addBookView        = addBookView;
            this._bookService        = bookService;
            this._apiServiceProvider = apiServiceProvider;

            // subscribe to the view's events
            this._view.IsbnFieldTextChanged += IsbnFieldTextChanged;
            this._view.SearchButtonClicked  += SearchButtonClicked;

            // enable scan mode by default
            this._view.ScanModeChecked = true;
        }
예제 #5
0
 public MockBookPresenter(IBookService bookRepo, ITagService tagService, IAuthorService authorService, IPublisherService publisherService, IAddBookForm view,
                          IImageFileReader imageFileReader)
     : base(bookRepo, tagService, authorService, publisherService, view, imageFileReader)
 {
 }
예제 #6
0
 public MockPresenter(ISearchByIsbn view, IMainWindow mainView, IAddBookForm addBookView,
                      IBookService bookRepo,
                      IApiServiceProvider apiServiceProvider)
     : base(view, addBookView, bookRepo, apiServiceProvider)
 {
 }