public async Task <IActionResult> Index(CancellationToken token) { if (!Request.Query.ContainsKey("companyId") || !Request.Query.ContainsKey("filmSessionId")) { return(NotFound()); } Request.Query.TryGetValue("companyId", out var companyId); var company = await _companyRepository.FindByIdAsync(long.Parse(companyId), token); Request.Query.TryGetValue("filmSessionId", out var filmSessionId); var currentFilmSession = await _filmSessionRepository.FindByIdAsync(long.Parse(filmSessionId), token); var poster = _blobRepository.Get(currentFilmSession.Film.Id); var tickets = (await _ticketRepository.FindByFilmSessionIdAsync(currentFilmSession.Id, token)).ToArray(); var unavailableSeats = new long[tickets.Length][]; for (var i = 0; i < tickets.Length; i++) { unavailableSeats[i] = new[] { tickets[i].Row, tickets[i].Column }; } var viewModel = new BookingViewModel { Company = company, Film = currentFilmSession.Film, FilmSession = currentFilmSession, Poster = poster, UnavailableSeats = JsonConvert.SerializeObject(unavailableSeats) }; return(View(viewModel)); }
public async Task <IActionResult> Index(TicketControlViewModel model, CancellationToken token, string returnUrl = null) { AddBreadcrumb("Ticket control", "/TicketControl"); ViewData["ReturnUrl"] = returnUrl; if (ModelState.IsValid) { var tickets = (await _ticketRepository.FindByConfirmationCodeAsync(model.ConfirmationCode, token)).ToList(); if (tickets.Count != 0) { model.FilmSession = await _filmSessionRepository.FindByIdAsync(tickets.First().FilmSession.Id, token); model.Tickets = tickets; } model.IsChecked = true; return(View(model)); } return(View(model)); }