コード例 #1
0
        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");
            }
        }
コード例 #2
0
        public static ShowOrder AssociatedShowWithOrder(Show show, TicketOrder ticketOrder)
        {
            ShowOrder showOrder = new ShowOrder()
            {
                Show = show, ShowId = show.ShowId, TicketOrder = ticketOrder, TicketOrderId = ticketOrder.TicketOrderId
            };

            return(showOrder);
        }