private void btnRent_Click(object sender, EventArgs e) { if (lvwVideoStatus.SelectedItems.Count.Equals(0)) { MessageBox.Show("Please select a video from list"); } else { try { var videoId = Guid.Parse(lvwVideoStatus.SelectedItems[0].Text); var customerId = ((Customer) cboRentCustomerName.SelectedItem).Id; var booking = new Booking(database); var result = booking.RentVideo(videoId, customerId, DateTime.Now); var videolist = GetVideoByStatus(); lvwVideoStatus.Items.Clear(); lvwVideoStatus.Items.AddRange(videolist.ToArray()); FillBookingList(); } catch (VideoRentalException ex) { MessageBox.Show(String.Format("Error occured: Rent {0} is not completed succesfully", ex.Item.Name)); } catch (Exception ex) { MessageBox.Show(string.Format("Error Occoured: {0}", ex.Message)); } } }
private void btnRent_Click(object sender, EventArgs e) { if (lvwVideoStatus.SelectedItems.Count.Equals(0)) { MessageBox.Show("Please select a video from list"); } else { try { var videoId = Guid.Parse(lvwVideoStatus.SelectedItems[0].Text); var customerId = ((Customer)cboRentCustomerName.SelectedItem).Id; var booking = new Booking(DbManager); var result = booking.RentVideo(new VideoBooking() { VideoId = videoId, CustomerId = customerId, RentDate = DateTime.Now, ReturnDate = DateTime.Now }); FillAvailableVideoList(); FillBookingList(); } catch (VideoRentalException ex) { MessageBox.Show(String.Format("Error occured: Rent {0} is not completed succesfully", ex.Item.Name)); } catch (Exception ex) { MessageBox.Show(string.Format("Error Occoured: {0}", ex.Message)); } } }