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

            // we create only one context in our application, which gets shared among repositories
            LibraryContext context = new LibraryContext();
            // we use a factory object that will create the repositories as they are needed, it also makes
            // sure all the repositories created use the same context.
            RepositoryFactory repFactory = new RepositoryFactory(context);

            // Service intialization
            this.bookService     = new BookService(repFactory);
            this.authorService   = new AuthorService(repFactory);
            this.bookCopyService = new BookCopyService(repFactory);
            this.memberService   = new MemberService(repFactory);
            this.loanService     = new LoanService(repFactory);

            // Event declaration
            this.bookService.Updated     += BookService_Updated;
            this.authorService.Updated   += AuthorService_Updated;
            this.memberService.Updated   += MemberService_Updated;
            this.loanService.Updated     += LoanService_Updated;
            this.bookCopyService.Updated += BookCopyService_Updated;

            // Start up methods that populate the lists
            ShowAllBooks(bookService.All());
            ShowAllAuthors(authorService.All());
            ShowAvailableCopies(bookCopyService.AllAvailable());
        }
Beispiel #2
0
        public CreateNewLoan(MemberService ms, LoanService ls, int mId, BookCopyService bk)
        {
            memberService   = ms;
            loanService     = ls;
            bookCopyService = bk;
            memberId        = mId;

            InitializeComponent();

            bookCopyService.Updated += BookCopyService_Updated;
            memberService.Updated   += MemberService_Updated;
            loanService.Updated     += LoanService_Updated;
            ShowAvailableCopies(bookCopyService.AllAvailable());
        }
Beispiel #3
0
 private void LoanService_Updated(object sender, EventArgs e)
 {
     ShowAvailableCopies(bookCopyService.AllAvailable());
 }