private void AddNewLoan() { Loan loan = new Loan(); EditLoanWindow EditLoanWindow = new EditLoanWindow(loan); if (EditLoanWindow.ShowDialog() == true) { if (AppViewModel.AddLoan(loan)) { PullAllLoans(); } else { throw new Exception("Add Loan Failed!"); } } }
private void ChangeLoan(Loan loan) { if (loan == null) { MessageBox.Show("Wählen Sie bitte eine Ausleihe in der Liste aus"); return; } Loan editableLoan = new Loan { Id = loan.Id, CustomerId = loan.CustomerId, GadgetId = loan.GadgetId, PickupDate = loan.PickupDate, ReturnDate = loan.ReturnDate }; EditLoanWindow EditLoanWindow = new EditLoanWindow(editableLoan); if (EditLoanWindow.ShowDialog() == true) { loan.Id = editableLoan.Id; loan.CustomerId = editableLoan.CustomerId; loan.GadgetId = editableLoan.GadgetId; loan.PickupDate = editableLoan.PickupDate; loan.ReturnDate = editableLoan.ReturnDate; if (AppViewModel.UpdateLoan(loan)) { PullAllLoans(); } else { throw new Exception("Update Loan Failed!"); } } }