Пример #1
0
        public ActionResult FindSeats(string tenant, int eventId)
        {
            if (eventId != 0)
            {
                SetTenantConfig(tenant);

                var eventDetails = _eventsRepository.GetEvent(eventId, _connectionString, Startup.TenantConfig.TenantId);

                if (eventDetails != null)
                {
                    var eventSections  = _eventSectionRepository.GetEventSections(eventId, _connectionString, Startup.TenantConfig.TenantId);
                    var seatSectionIds = eventSections.Select(i => i.SectionId).ToList();

                    var seatSections = _sectionRepository.GetSections(seatSectionIds, _connectionString, Startup.TenantConfig.TenantId);
                    if (seatSections != null)
                    {
                        var ticketsSold = _ticketRepository.GetTicketsSold(seatSections[0].SectionId, eventId, _connectionString, Startup.TenantConfig.TenantId);

                        FindSeatViewModel viewModel = new FindSeatViewModel
                        {
                            EventDetails   = eventDetails,
                            SeatSections   = seatSections,
                            SeatsAvailable = (seatSections[0].SeatRows * seatSections[0].SeatsPerRow) - ticketsSold
                        };

                        return(View(viewModel));
                    }
                }
            }
            return(RedirectToAction("Index", "Events", new { tenant = Startup.TenantConfig.TenantName }));
        }
Пример #2
0
        public void GetEventSectionsTest()
        {
            _eventSectionRepository = new MockEventSectionRepository();
            _connectionString       = "User ID=developer;Password=password;Connect Timeout=0;Application Name=EntityFramework";
            _tenantId = 1368421345;

            var result = _eventSectionRepository.GetEventSections(1, _connectionString, _tenantId);

            Assert.IsNotNull(result);
            Assert.AreEqual(3, result.Count);
            Assert.AreEqual(1, result[0].SectionId);
            Assert.AreEqual(1, result[0].EventId);
            Assert.AreEqual(100, result[0].Price);
            Assert.AreEqual(2, result[1].SectionId);
            Assert.AreEqual(1, result[1].EventId);
            Assert.AreEqual(80, result[1].Price);
            Assert.AreEqual(3, result[2].SectionId);
            Assert.AreEqual(1, result[2].EventId);
            Assert.AreEqual(60, result[2].Price);
        }