コード例 #1
0
        public List<SeatSectionLayoutViewModel> GetSeatSectionLayout(int concertId, int ticketLevelId)
        {
            using (var context = new WingTipTicketsEntities(WingtipTicketApp.GetTenantConnectionString()))
            {
                var ticketLevel = context.TicketLevels.First(t => t.TicketLevelId == ticketLevelId);

                var result = context.SeatSectionLayouts.Where(l => l.SeatSectionId == ticketLevel.SeatSectionId).Select(l => new SeatSectionLayoutViewModel()
                {
                    RowNumber = (int)l.RowNumber,
                    SkipCount = (int)l.SkipCount,
                    StartNumber = (int)l.StartNumber,
                    EndNumber = (int)l.EndNumber,
                    SelectedSeats = context.Tickets
                        .Where(t => t.TicketLevelId == ticketLevelId &&
                                    t.ConcertId == concertId &&
                                    t.SeatNumber >= (int)l.StartNumber &&
                                    t.SeatNumber <= (int)l.EndNumber)
                        .Select(t => (int)t.SeatNumber)
                        .Distinct()
                        .ToList()
                }).ToList();

                return result;
            }
        }
コード例 #2
0
        public FindSeatsViewModel GetFindSeatsData(int concertId)
        {
            using (var context = new WingTipTicketsEntities(WingtipTicketApp.GetTenantConnectionString()))
            {
                var concert = context.Concerts.First(c => c.ConcertId == concertId);
                var venue = context.Venues.First(v => v.VenueId == concert.VenueId);
                var performer = context.Performers.First(p => p.PerformerId == concert.PerformerId);

                var seatSections = context.TicketLevels.Where(t => t.ConcertId == concertId).ToList();

                // Map to ViewModel
                var viewModel = new FindSeatsViewModel()
                {
                    // Main Models
                    Concert = new FindSeatsViewModel.ConcertViewModel()
                    {
                        ConcertId = concert.ConcertId,
                        ConcertName = concert.ConcertName,
                        ConcertDate = (DateTime)concert.ConcertDate,

                        VenueId = venue.VenueId,
                        VenueName = venue.VenueName,

                        PerformerName = performer.ShortName
                    },

                    // Collections
                    SeatSections = new SelectList(seatSections, "TicketLevelId", "Description", null),
                };

                return viewModel;
            }
        }
コード例 #3
0
 public string GetApplicationDefault(string code)
 {
     using (var context = new WingTipTicketsEntities(WingtipTicketApp.GetTenantConnectionString(WingtipTicketApp.Config.TenantDatabase1)))
     {
         return context.ApplicationDefaults.First(a => a.Code.Equals(code)).Value;
     }
 }
コード例 #4
0
        public void SetApplicationDefault(string code, string value)
        {
            using (var context = new WingTipTicketsEntities(WingtipTicketApp.GetTenantConnectionString(WingtipTicketApp.Config.TenantDatabase1)))
            {
                var setting = context.ApplicationDefaults.First(a => a.Code.Equals(code));
                setting.Value = value;

                context.SaveChanges();
            }
        }