示例#1
0
        public ActionResult Create([Bind(Include = "ID,ShowID,ShowTitle,Row,Number")] Ticket ticket)
        {
            ShowService showService  = new ShowService();
            var         ticketNumber = showService.getTicketNumbers(ticket.ShowID);

            TicketService ticketService       = new TicketService();
            var           currentTicketNumber = ticketService.getCountTickets(ticket.ShowID);


            if (ticketNumber > currentTicketNumber)
            {
                bool OK = ticketService.checkSeat(ticket.ShowID, ticket.Row, ticket.Number);
                if (OK)
                {
                    if (ModelState.IsValid)
                    {
                        db.Tickets.Add(ticket);
                        db.SaveChanges();
                        return(RedirectToAction("Index"));
                    }
                }
                else
                {
                    TempData["Message"] = "Seat taken!";
                }
            }
            else
            {
                TempData["Message2"] = "Tickets Sold Out!";
            }
            return(RedirectToAction("Create"));
        }