Exemplo n.º 1
0
        /// <summary>
        /// demonstrates the use of the admin functions to add/remove
        /// new loans and reservations to/from the gadgeothek
        /// (internally a bit more complicated since holding
        /// referenced values)
        /// </summary>
        public void ShowAdminInteractionForLoans()
        {
            var service = new LibraryAdminService(ServerUrl);

            var rnd      = new Random();
            var randomId = rnd.Next(100000, 999999).ToString();

            var android = service.GetGadget("26");   // Android2
            var michael = service.GetCustomer("10"); // Michael
            var loan    = new Loan(randomId, android, michael, DateTime.Today.AddDays(-1), null);

            if (!service.AddLoan(loan))
            {
                Console.WriteLine($"{loan} konnte nicht hinzugefügt werden werden...");
                return;
            }

            var loans = service.GetAllLoans();

            PrintAll(loans, "Loans (NEW)");

            loan.ReturnDate = DateTime.Now;
            if (!service.UpdateLoan(loan))
            {
                Console.WriteLine($"{loan} konnte nicht aktualisiert werden...");
                return;
            }


            loans = service.GetAllLoans();
            PrintAll(loans, "Loans (NEW 2)");;

            if (!service.DeleteLoan(loan))
            {
                Console.WriteLine($"{loan} konnte nicht gelöscht werden...");
                return;
            }

            loans = service.GetAllLoans();
            PrintAll(loans, "Loans (NEW 3)");
        }
Exemplo n.º 2
0
 public bool DeleteLoan(Loan loan)
 {
     return(Service.DeleteLoan(loan));
 }