private void ValidateBtn_Click(object sender, RoutedEventArgs e)
        {
            if (QuantityTxtBox.Text != "0" && QuantityTxtBox.Text != String.Empty && TotalPriceTxtBlock.Text != String.Empty)
            {
                using (var context = new CircusDataContext())
                {
                    Ticket newTicket = new Ticket();
                    newTicket.ShowName    = SelectedShow.Name;
                    newTicket.TicketPrice = SelectedShow.TicketPrice;
                    newTicket.StartTime   = SelectedEvent.StartTime;
                    newTicket.EndTime     = SelectedEvent.EndTime;

                    context.Add(newTicket);

                    Order newOrder = new Order();
                    newOrder.Quantity   = Convert.ToInt32(QuantityTxtBox.Text);
                    newOrder.OrderPrice = Convert.ToDouble(TotalPriceTxtBlock.Text);
                    newOrder.OrderDate  = DateTime.Now;
                    newOrder.Ticket     = newTicket;

                    context.Add(newOrder);
                    context.SaveChanges();
                }

                MessageBox.Show("Your ticket(s) is(are) sent to your mailbox");
                this.Close();
            }
            else
            {
                MessageBox.Show("If you want to buy tickets please insert a valid quantity number (not \"0\") and click OK to get the total price");
            }
        }
Пример #2
0
 public static List <Show> DisplayAllShows()
 {
     using (var context = new CircusDataContext())
     {
         var defaultList = (from s in context.Show
                            select s).ToList();
         return(defaultList);
     }
 }
Пример #3
0
 public static List <Order> GetAllOrders()
 {
     using (var context = new CircusDataContext())
     {
         var ordersList = (from o in context.Order
                           select o).ToList();
         return(ordersList);
     }
 }
Пример #4
0
 public static Show GetShowFromEvent(Event oneEvent)
 {
     using (var context = new CircusDataContext())
     {
         var show = (from s in context.Show
                     join se in context.ShowEvent
                     on s.Id equals se.ShowId
                     where se.EventId == oneEvent.Id
                     select s).FirstOrDefault();
         return(show);
     }
 }
Пример #5
0
        /*public static dynamic GetShowInfoAndTroupeNameFromShow(Show show)
         * {
         *  using (var context = new CircusDataContext())
         *  {
         *      var shopInfoWithTroupeName = (from s in context.Show
         *                         join t in context.Troupe
         *                         on s.Troupe.Id equals t.Id
         *                         where s.Troupe.Id == show.Id
         *                         select new { s.Name, s.Description,troupeName=t.Name }).ToList();
         *      return shopInfoWithTroupeName;
         *
         *      List<EditionInfos> editionInfosLine = editionList.Select(s => new EditionInfos
         *      {
         *          EditionId = s.EditionId.ToString(),
         *          EditionNumber = s.EditionNumber.ToString(),
         *          PublicationDate = s.PublicationDate.ToString("MM/dd/yyyy"),
         *          MagazineName = s.Name.ToString(),
         *      }).ToList();
         *      return editionInfosLine;
         *  }
         * } */

        public static List <Event> GetEventListFromShow(Show show)
        {
            using (var context = new CircusDataContext())
            {
                var eventlist = (from e in context.Event
                                 join se in context.ShowEvent
                                 on e.Id equals se.EventId
                                 where se.ShowId == show.Id
                                 select e).ToList();
                return(eventlist);
            }
        }
Пример #6
0
 public static Troupe GetTroupeFromShow(Show show)
 {
     using (var context = new CircusDataContext())
     {
         var troupe = (from s in context.Show
                       join t in context.Troupe
                       on s.Troupe.Id equals t.Id
                       where t.Id == show.Id
                       select t).FirstOrDefault();
         return(troupe);
     }
 }