Example #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)");
        }
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            String ServerUrl = "http://localhost:8080";
            var    service   = new LibraryAdminService(ServerUrl);

            Customer customer = service.GetCustomer(tbStudentID.Text);
            DateTime time     = DateTime.Now;
            String   gadgetID = tbGadgetID.Text;



            Loan loan = new Loan(
                tbLoanID.Text,
                service.GetGadget(gadgetID),
                service.GetCustomer(tbStudentID.Text),
                time,
                time.AddDays(30)
                );

            service.AddLoan(loan);

            this.DialogResult = true;
        }
Example #3
0
 public bool AddLoan(Loan loan)
 {
     return(Service.AddLoan(loan));
 }