private void Validate_btn_Click(object sender, RoutedEventArgs e) { if (Quantity_ComboBox.SelectedItem != null) { var context = new CircusContext(); var ticketOrder = new TicketOrder() { Price = Convert.ToDecimal(Price_TextBlock.Text), TicketNumber = Convert.ToInt32(Quantity_ComboBox.SelectedItem), OrderDate = DateTime.Today, }; ShowOrder showOrder = CircusInformation.AssociatedShowWithOrder(SelectedShow, ticketOrder); ticketOrder.ManyShowOrder.Add(showOrder); context.Update(ticketOrder); context.SaveChanges(); MessageBox.Show("Ticket(s) ordered for the show : " + SelectedShow.Name); this.Close(); } else { MessageBox.Show("Select a quantity"); } }
private void AddShow_Button_Click(object sender, RoutedEventArgs e) { if (IsAllBoxFilled() == true) { var context = new CircusContext(); Show newShow = new Show(); newShow.Name = Name_TextBox.Text; newShow.Date = Date_DatePicker.SelectedDate.Value; newShow.Location = Location_TextBox.Text; newShow.Price = Convert.ToInt32(Price_TextBox.Text); List <Performer> selectedPerformers = new List <Performer>(); foreach (var item in Performers_ListBox.SelectedItems) { Performer performer = (Performer)item; selectedPerformers.Add(performer); } List <PerformerShow> performerShows = CircusInformation.AssociatedShowWithPerformer(newShow, selectedPerformers); newShow.ManyPerformerShow.AddRange(performerShows); context.Update(newShow); context.SaveChanges(); MessageBox.Show("New Show added"); } else { MessageBox.Show("You must filled every fields"); } }