Exemple #1
0
        public async Task <IActionResult> Index(BookingViewModel model, CancellationToken token)
        {
            var places = JsonConvert.DeserializeObject <long[][]>(model.Places);

            var bookingId        = Guid.NewGuid();
            var confirmationCode = GenerateCode();

            foreach (var place in places)
            {
                var ticket = new Ticket
                {
                    BookingId        = bookingId,
                    ConfirmationCode = confirmationCode,
                    Email            = model.Email,
                    Phone            = model.Phone,
                    Row         = place[0],
                    Column      = place[1],
                    FilmSession = await _filmSessionRepository.FindByIdAsync(model.FilmSession.Id, token)
                };

                await _ticketRepository.AddAsync(ticket, token);
            }

            var routeValuesDictionary = new RouteValueDictionary
            {
                { "companyId", model.Company.Id }, { "bookingId", bookingId }
            };

            return(RedirectToAction(nameof(Info), "Booking", routeValuesDictionary));
        }