Пример #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 async Task <ActionResult> FindSeats(string tenant, int eventId)
        {
            try
            {
                if (eventId != 0)
                {
                    var tenantDetails = (_catalogRepository.GetTenant(tenant)).Result;
                    if (tenantDetails != null)
                    {
                        SetTenantConfig(tenantDetails.TenantId, tenantDetails.TenantIdInString);

                        var eventDetails = await _tenantRepository.GetEvent(eventId, tenantDetails.TenantId);

                        if (eventDetails != null)
                        {
                            var eventSections = await _tenantRepository.GetEventSections(eventId, tenantDetails.TenantId);

                            var seatSectionIds = eventSections.Select(i => i.SectionId).ToList();

                            var seatSections = await _tenantRepository.GetSections(seatSectionIds, tenantDetails.TenantId);

                            if (seatSections != null)
                            {
                                var ticketsSold = await _tenantRepository.GetTicketsSold(seatSections[0].SectionId, eventId, tenantDetails.TenantId);

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

                                return(View(viewModel));
                            }
                        }
                    }
                    else
                    {
                        return(View("TenantError", tenant));
                    }
                }
            }
            catch (Exception ex)
            {
                _logger.LogError(0, ex, "FindSeats failed for tenant {tenant} and event {eventId}", tenant, eventId);
                return(View("TenantError", tenant));
            }
            return(RedirectToAction("Index", "Events", new { tenant }));
        }