Exemplo n.º 1
0
        public static TicketPurchaseModel CreateTicket(EventModel Event, int tktQty)
        {
            TicketPurchaseModel ticket = new TicketPurchaseModel();

            ticket.Id             = Guid.NewGuid();
            ticket.Event          = Event;
            ticket.TicketQuantity = tktQty;

            return(ticket);
        }
Exemplo n.º 2
0
        //This method creates a TicketPurchase that matches the reserved ticket.
        public TicketPurchaseModel PurchaseTicketWith(Guid reservationId)
        {
            //check if ticket purchase is possible with a certain reservation Id
            if (!CanPurchaseTicketWith(reservationId))
            {
                throw new ApplicationException(
                          DetermineWhyTicketCannotbePurchasedWith(reservationId));
            }

            //get the reservation assigned to the reservation Id
            TicketReservationModel reservation = GetReservationWith(reservationId);

            //Create a new ticket
            TicketPurchaseModel ticket = TicketPurchaseFactory.CreateTicket(this, reservation.TicketQuantity);

            reservation.HasBeenRedeemed = true;

            PurchasedTickets.Add(ticket);

            return(ticket);
        }