public async Task <IActionResult> CreateNewTicket(CreateTicketViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }

            await ticketRepository.AddTicketAsync(viewModel.Ticket);

            await ticketRepository.CommitAsync();

            return(RedirectToAction("Index"));
        }
示例#2
0
        private async Task <TicketEntity> SaveTicketAsync(TicketWriteModel ticket)
        {
            var ticketEntity = (TicketEntity)ticket;

            await FindEventsRatesAsync(ticketEntity);
            await FindEventResultsAsync(ticketEntity.Events);

            await ReduceUserAccountBalanceAsync(ticket.UserId, ticket.Stake);

            var createdTicket = await _ticketRepository.AddTicketAsync(ticketEntity);

            await _ticketRepository.SaveChangesAsync();

            return(createdTicket);
        }
示例#3
0
        public async Task <bool> CreateTicket(ReserveTicketResource resource)
        {
            List <Ticket> list = new List <Ticket>();

            foreach (var seat in resource.SeatId)
            {
                list.Add(new Ticket()
                {
                    EventId = resource.EventId,
                    SeatId  = seat,
                    UserId  = resource.UserId
                });
            }

            await _ticketRepository.AddTicketAsync(list);

            return(true);
        }