public IActionResult Create([FromBody] TicketPurchaseJSON ticketPurchase)
        {
            TicketPurchaseRepository ticketPurchaseRepo = new TicketPurchaseRepository(_context);

            if (ticketPurchase.EventSeatsPurchased.Count == 0)
            {
                return(BadRequest("No Seats In Transaction"));
            }
            else if (String.IsNullOrWhiteSpace(ticketPurchase.PaymentMethod))
            {
                return(BadRequest("Payment Method Missing"));
            }
            else if (ticketPurchase.PaymentAmount < 0)
            {
                return(BadRequest("Payment Amount Cannot Be Negative"));
            }
            else if (String.IsNullOrWhiteSpace(ticketPurchase.ConfirmationCode))
            {
                return(BadRequest("Payment Amount Cannot Be Negative"));
            }

            if (!ticketPurchaseRepo.CreateTicketPurchase(ticketPurchase))
            {
                return(BadRequest("Unable To Purchase Seats, Please Check Your Transaction Details (e.g Seat May Not Be Available For Sale) and Try Again"));
            }

            return(new ObjectResult(ticketPurchase));
        }
        public bool CreateTicketPurchase(TicketPurchaseJSON ticketPurchase)
        {
            bool isSuccessful = false;

            try {
                TicketPurchase purchase = new TicketPurchase {
                    PaymentMethod    = ticketPurchase.PaymentMethod,
                    PaymentAmount    = ticketPurchase.PaymentAmount,
                    ConfirmationCode = ticketPurchase.ConfirmationCode
                };

                _context.TicketPurchase.Add(purchase);

                foreach (int eventSeatId in ticketPurchase.EventSeatsPurchased)
                {
                    EventSeat seat = _context.EventSeat
                                     .Where(es => es.EventSeatId == eventSeatId)
                                     .FirstOrDefault();

                    if (seat != null && seat.TicketPurchase == null)
                    {
                        seat.TicketPurchase = purchase;
                    }
                    else
                    {
                        _context.TicketPurchase.Remove(purchase);
                        _context.SaveChanges();
                        throw new System.ArgumentException("Seat ID Invalid");
                    }
                }

                _context.SaveChanges();
                isSuccessful = true;
            } catch (Exception e) {
            }


            return(isSuccessful);
        }