private void loanButton_Click(object sender, RoutedEventArgs e) { Library selectedItemCatalogus = (Library)CatalogusListbox.SelectedItem; Students selectedStudent = (Students)StudentListbox.SelectedItem; if (CatalogusListbox.SelectedItem != null && StudentListbox.SelectedItem != null) { Loans newLoan = new Loans(); newLoan.StudentId = selectedStudent.Id; newLoan.LoanDate = DateTime.UtcNow; newLoan.itemId = selectedItemCatalogus.LibraryId; newLoan.ItemTitle = selectedItemCatalogus.Title; newLoan.ItemCreator = selectedItemCatalogus.Creator; newLoan.ItemProductNumber = selectedItemCatalogus.ProductNumber; newLoan.StudentFirstName = selectedStudent.FirstName; newLoan.StudentLastName = selectedStudent.LastName; newLoan.ReturnDateString = ""; newLoan.FinePayed = true; selectedItemCatalogus.ReserveStudentID = -1; loansRepository.CreateLoan(newLoan); selectedItemCatalogus.Availability = AvailabilityItem.Uitgeleend; selectedItemCatalogus.LoanerID = selectedStudent.Id; libraryRepository.UpdateLibraryItems(selectedItemCatalogus); MessageBox.Show($"{selectedStudent.FirstName} {selectedStudent.LastName} heeft volgend item uitgeleend: {selectedItemCatalogus.Title} "); } ShowLibraryInListbox(); }
private void LoanwithID() { Console.WriteLine($"Geef het ID nummer van het boek dat je wilt uitlenen."); Console.Write($"ID:"); int ID = Convert.ToInt32(Console.ReadLine()); Library bookChoice = libraryRepository.GetItemWith(ID); Console.WriteLine($"wil je {bookChoice.Title} - {bookChoice.Creator} uitlenen (J/N): "); string choice = Console.ReadLine().ToUpper(); if (choice == "J") { Loans newLoan = new Loans(); newLoan.StudentId = LoggedStudent.Id; newLoan.LoanDate = DateTime.UtcNow; newLoan.itemId = bookChoice.LibraryId; newLoan.ItemTitle = bookChoice.Title; newLoan.ItemCreator = bookChoice.Creator; newLoan.ItemProductNumber = bookChoice.ProductNumber; newLoan.StudentFirstName = LoggedStudent.FirstName; newLoan.StudentLastName = LoggedStudent.LastName; newLoan.ReturnDateString = ""; newLoan.FinePayed = true; loansRepository.CreateLoan(newLoan); bookChoice.Availability = AvailabilityItem.Uitgeleend; libraryRepository.UpdateLibraryItems(bookChoice); Console.WriteLine($"Je hebt volgende item uitgeleend: {bookChoice.Title} "); } else if (choice == "N") // nieuwe keuze maken { ShowLoanBookInterface(); } else { Console.WriteLine(" Invoer verkeerd: probeer opnieuw"); } Console.Write("Enter om terug naar menu te gaan."); Console.ReadKey(); ShowLoanBookInterface(); }