internal void ReturnBook()
        {
            Console.WriteLine("#################");
            Console.WriteLine("# BOEK inleveren #");
            Console.WriteLine("#################" + Environment.NewLine);


            List <Library> listOfLoans = libraryRepository.GetbookItemsLoanedBy(LoggedStudent);

            if (listOfLoans.Count == 0)
            {
                Console.WriteLine("Er zijn geen boeken uitgeleend!");
                Console.Write("Enter om terug naar menu te gaan.");
                Console.ReadKey();
            }
            else
            {
                Console.WriteLine("Lijst van uitgeleende Boeken");
                Console.WriteLine("================" + Environment.NewLine);
                foreach (Library item in listOfLoans)
                {
                    Console.WriteLine($"LeningID {item.LibraryId} - Titel: {item.Title} - Auteur: {item.Creator}");
                }
                Console.WriteLine($"Geef het ID van het boek dat je wilt terugbrengen.");
                int     ID         = Convert.ToInt32(Console.ReadLine());
                Library bookChoice = libraryRepository.GetItemWith(ID);
                Loans   loan       = loansRepository.GetLoanWith(ID, LoggedStudent.Id);
                loan.ReturnDateString = DateTime.UtcNow.ToShortDateString();
                loansRepository.UpdateLoan(loan);

                bookChoice.LoanerID = 0;
                if (bookChoice.ReserveStudentID != -1)
                {
                    bookChoice.Availability = AvailabilityItem.GereserveerdAanwezig;
                }
                else
                {
                    bookChoice.Availability = AvailabilityItem.Aanwezig;
                }
                libraryRepository.UpdateLibraryItems(bookChoice);


                Console.WriteLine($"Je hebt volgend item teruggebracht: {bookChoice.Title}.");
                Console.Write("Enter om terug naar menu te gaan.");
                Console.ReadKey();
            }
        }
예제 #2
0
        public void ShowFines()
        {
            Console.WriteLine("####################");
            Console.WriteLine("# OVERZICHT BOETES #");
            Console.WriteLine("####################" + Environment.NewLine);

            List <Loans> allloans = loansRepository.GetLoansOfStudent(LoggedStudent.Id);

            foreach (Loans loan in allloans)
            {
                if (loan.ReturnedOnTime == false && loan.FinePayed == false)
                {
                    Console.WriteLine($"ID: {loan.ID} - Titel: {loan.ItemTitle} - Auteur: {loan.ItemCreator} - Dagen te laat: {loan.Timespan}- Boete: {loan.Fine} € ");
                }
            }
            Console.Write($"Geef de ID van de Boete dat je zou willen betalen:");
            int   id           = Convert.ToInt32(Console.ReadLine());
            Loans Selectedloan = loansRepository.GetLoanWithLoanID(id);

            Console.WriteLine($" {Selectedloan.Fine} € BETAALD.");
            Selectedloan.FinePayed = true;
            loansRepository.UpdateLoan(Selectedloan);
        }
        private void BringBackLoanedBook()
        {
            Loans    selectedloan    = (Loans)LoansListbox.SelectedItem;
            Students selectedStudent = (Students)StudentListbox.SelectedItem;
            Library  libraryItem     = libraryRepository.GetLibraryItemWithID(selectedloan.itemId);

            selectedloan.ReturnDateString = DateTime.UtcNow.ToShortDateString();
            loansRepository.UpdateLoan(selectedloan);


            if (libraryItem.ReserveStudentID != -1)
            {
                libraryItem.Availability = AvailabilityItem.GereserveerdAanwezig;
            }
            else
            {
                libraryItem.Availability = AvailabilityItem.Aanwezig;
            }
            libraryItem.LoanerID = 0;

            libraryRepository.UpdateLibraryItems(libraryItem);
            MessageBox.Show($"{selectedStudent.FirstName} {selectedStudent.LastName} heeft volgend item teruggebracht: {libraryItem.Title}."
                            + Environment.NewLine + ShowFine(selectedloan));
        }