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); bookService = new BookService(repFactory); copyService = new BookCopyService(repFactory); authorService = new AuthorService(repFactory); memberService = new MemberService(repFactory); returnedLoanService = new ReturnedLoanService(repFactory); loanService = new LoanService(repFactory, returnedLoanService); ShowAllBooks(bookService.All()); ShowAllBookCopies(copyService.All()); ShowAllMembers(memberService.All()); ShowAllAuthors(authorService.All()); ShowAllLoans(loanService.All()); ShowAllAvailableBooks(copyService.All(), loanService.All()); ShowAllOverDueBooks(copyService.All()); bookService.Updated += BookService_Updated; authorService.Updated += AuthorService_Updated; copyService.Updated += CopyService_Updated; memberService.Updated += MemberService_Updated; loanService.Updated += LoanService_Updated; backgroundWorker1.DoWork += BackgroundWorker1_DoWork; backgroundWorker1.RunWorkerCompleted += BackgroundWorker1_RunWorkerCompleted; }
/// <summary> /// Sets the fields to their proper values. /// </summary> /// <param name="returnedLoan"></param> /// <param name="returnedLoanService"></param> public AboutHistoryForm(ReturnedLoan returnedLoan, ReturnedLoanService returnedLoanService) { RLS = returnedLoanService; RL = returnedLoan; InitializeComponent(); lbl_BookTitle.Text = RL.BookCopy.Book.Title; txt_TimeOfLoan.Text = RL.TimeOfLoan.ToString(); txt_TimeOfReturn.Text = RL.TimeOfReturn.ToString(); }