Example #1
0
        public LibraryForm()
        {
            InitializeComponent();

            RepositoryFactory repoFactory = new RepositoryFactory();

            _bookService     = new BookService(repoFactory);
            _bookCopyService = new BookCopyService(repoFactory);
            _authorService   = new AuthorService(repoFactory);
            _loanService     = new LoanService(repoFactory);
            _memberService   = new MemberService(repoFactory);


            //Subscribe to event
            _bookService.Updated     += ListAllBooks;
            _bookCopyService.Updated += ListAllBookCopies;
            _authorService.Updated   += ListAllAuthors;
            _loanService.Updated     += ListAllLoans;
            _memberService.Updated   += ListAllMembers;

            //Call the event to print to print the "test-objects"
            _authorService.OnChanged(this, EventArgs.Empty);
            _bookService.OnChanged(this, EventArgs.Empty);
            _bookCopyService.OnChanged(this, EventArgs.Empty);
            _loanService.OnChanged(this, EventArgs.Empty);
            _memberService.OnChanged(this, EventArgs.Empty);
        }
Example #2
0
        private void btnCopy_Click(object sender, EventArgs e)
        {
            BookCopy kopia = new BookCopy();

            //Buy a copy of a selected book from the list
            if (lbBooks.SelectedItem != null)
            {
                kopia.Book = (Book)lbBooks.SelectedItem;
                _bookCopyService.Add(kopia);
                _bookCopyService.OnChanged(this, EventArgs.Empty);
            }
            else
            {
                MessageBox.Show("You have to select a book to make a copy!");
            }
        }