//adding sample data into the instock list and current customers list private void Window_Loaded(object sender, RoutedEventArgs e) { DataRepo.InStock = DataRepo.GetMovies(); DataRepo.CurrentCustomers = DataRepo.GetCustomers(); frame.NavigationService.Navigate(new Main()); }
//when you select a movie that movie can be returned to the instock list private void BtnReturn_Click(object sender, RoutedEventArgs e) { Loan selectedLoan = lbxMovies.SelectedItem as Loan; if (selectedLoan != null) { DataRepo.UpdateStockAdd(selectedLoan.MyMovie); DataRepo.AllLoans.Remove(selectedLoan); lbxMovies.ItemsSource = null; lbxMovies.ItemsSource = DataRepo.AllLoans; } }
//when the button is clicked stock is changed and a new loan is created. The new loan is passed through to the ReceiptPage. private void btnCreate_Click(object sender, RoutedEventArgs e) { Movie selected = lbxStock.SelectedItem as Movie; if (selected != null && days != 0) { DataRepo.UpdateStockRemove(selected); Loan NewLoan = new Loan(selected, days); DataRepo.AllLoans.Add(NewLoan); DataRepo.InStock = TempStock; this.NavigationService.Navigate(new ReceiptPage(NewLoan)); } else { MessageBox.Show("You have to select at least one movie and rent for at least one day"); } }