コード例 #1
0
        public static PresentationInfo GetPresInfoByPres(Presentation pres)
        {
            using (var context = new ShowContext())
            {
                List <Presentation> presentations = (from p in context.Presentations
                                                     select p).ToList();
                List <Show> shows = (from s in context.Shows
                                     select s).ToList();
                List <Order> orders = (from o in context.Orders
                                       select o).ToList();
                List <Room> rooms = (from r in context.Rooms
                                     select r).ToList();
                var presInfo = (from p in presentations
                                join s in shows on p.Show.ShowId equals s.ShowId
                                join o in orders on p.PresentationId equals o.Presentation.PresentationId
                                join r in rooms on p.Room.RoomId equals r.RoomId
                                where p.PresentationId == pres.PresentationId
                                select new { s.Name, p.PresentationDate, o.ReservedSeats, r.TotalSeats }).ToList();

                PresentationInfo presInfosLine = presInfo.GroupBy(x => x.Name)
                                                 .Select(s => new PresentationInfo
                {
                    ShowName            = s.First().Name,
                    PresentationDate    = s.First().PresentationDate,
                    ReservedSeatCount   = s.Sum(o => o.ReservedSeats),
                    TotalSeatCount      = s.First().TotalSeats,
                    AvailableSeatsCount = s.First().TotalSeats - s.Sum(o => o.ReservedSeats)
                }).FirstOrDefault();
                return(presInfosLine);
            }
        }
コード例 #2
0
        private void DisplayAllPresInfoList()
        {
            List <PresentationInfo> presentationInfoList = new List <PresentationInfo>();

            AllPresentationList = DisplayInformation.GetAllPresentationList();
            foreach (Presentation pres in AllPresentationList)
            {
                PresInfoByShow = DisplayInformation.GetPresInfoByPres(pres);
                presentationInfoList.Add(PresInfoByShow);
            }
            PresentationInfosListView.ItemsSource = presentationInfoList;
        }
コード例 #3
0
        public OrderWindow(MainWindow owner)
        {
            InitializeComponent();
            this.Owner       = owner;
            DataContext      = owner.PresentationInfosListView.SelectedItem;
            SelectedPresInfo = (PresentationInfo)DataContext;
            string selectedShowName = SelectedPresInfo.ShowName;

            ShowNameTextBlock.Text = selectedShowName;
            string selectedPresDate = SelectedPresInfo.PresentationDate.ToString("MM/dd/yyyy");

            PresentationDateTextBlock.Text = selectedPresDate;
            CurrentPresAvailableSeats      = SelectedPresInfo.AvailableSeatsCount;
            AvailableSeatsTextBlock.Text   = CurrentPresAvailableSeats.ToString();
        }
コード例 #4
0
 private void FilterSelectedDisplay()
 {
     if (IsShowAndPeriodSelected())
     {
         DateTime selectedStartDate = StartDatePicker.SelectedDate.Value.Date;
         DateTime selectedEndDate   = EndDatePicker.SelectedDate.Value.Date;
         string   selectedShowName  = ShowListComboBox.Text;
         Show     selectedShow      = DisplayInformation.GetShowByName(selectedShowName);
         List <PresentationInfo> presListWithShowFilter = new List <PresentationInfo>();
         List <Presentation>     allPresList            = DisplayInformation.GetAllPresentationList();
         List <Presentation>     selectedPresList       = allPresList.Where(p => p.Show.ShowId == selectedShow.ShowId).ToList();
         foreach (Presentation pres in selectedPresList)
         {
             PresentationInfo presInfoByShow = DisplayInformation.GetPresInfoByPres(pres);
             presListWithShowFilter.Add(presInfoByShow);
         }
         List <PresentationInfo> presListWithPeriodFilter = presListWithShowFilter.Where(p => p.PresentationDate >= selectedStartDate && p.PresentationDate <= selectedEndDate).ToList();
         PresentationInfosListView.ItemsSource = presListWithPeriodFilter.Distinct();
     }
     else if (IsOnlyShowSelected())
     {
         string selectedShowName = ShowListComboBox.Text;
         Show   selectedShow     = DisplayInformation.GetShowByName(selectedShowName);
         List <PresentationInfo> presentationInfoList = new List <PresentationInfo>();
         List <Presentation>     allPresList          = DisplayInformation.GetAllPresentationList();
         List <Presentation>     selectedPresList     = allPresList.Where(p => p.Show.ShowId == selectedShow.ShowId).ToList();
         foreach (Presentation pres in selectedPresList)
         {
             PresentationInfo presInfoByShow = DisplayInformation.GetPresInfoByPres(pres);
             presentationInfoList.Add(presInfoByShow);
         }
         PresentationInfosListView.ItemsSource = presentationInfoList.Distinct();
     }
     else if (IsOnlyPeriodSelected())
     {
         DateTime selectedStartDate = StartDatePicker.SelectedDate.Value.Date;
         DateTime selectedEndDate   = EndDatePicker.SelectedDate.Value.Date;
         List <PresentationInfo> presentationInfoList = new List <PresentationInfo>();
         AllPresentationList = DisplayInformation.GetPresListByPeriod(selectedStartDate, selectedEndDate);
         foreach (Presentation pres in AllPresentationList)
         {
             PresentationInfo presInfoByShow = DisplayInformation.GetPresInfoByPres(pres);
             presentationInfoList.Add(presInfoByShow);
         }
         PresentationInfosListView.ItemsSource = presentationInfoList.Distinct();
     }
 }
コード例 #5
0
        public MainWindow()
        {
            InitializeComponent();
            AllShowList = DisplayInformation.GetAllDefaultShows();
            List <string> showNameList = AllShowList.Select(s => s.Name).ToList();

            ShowListComboBox.ItemsSource = showNameList;

            List <PresentationInfo> presentationInfoList = new List <PresentationInfo>();

            AllPresentationList = DisplayInformation.GetAllPresentationList();
            foreach (Presentation pres in AllPresentationList)
            {
                PresInfoByShow = DisplayInformation.GetPresInfoByPres(pres);
                presentationInfoList.Add(PresInfoByShow);
            }
            PresentationInfosListView.ItemsSource = presentationInfoList;
        }