Exemplo n.º 1
0
        /// <inheritdoc />
        public void CancelTicket(Ticket ticket)
        {
            if (ticket == null)
            {
                throw new ArgumentNullException("ticket");
            }

            if (ticket.Seat == null)
            {
                throw new ArgumentNullException("ticket.Seat");
            }

            if (ticket.Seat.Session == null)
            {
                throw new ArgumentNullException("ticket.Seat.Session");
            }

            if (ticket.Seat.Session.Status == SessionStatus.Closed)
            {
                throw new CinematicException(Messages.SessionIsClosedCannotReturnTickets);
            }

            SeatManager.DeallocateSeat(ticket.Seat);

            DataContext.Remove(ticket);
        }
Exemplo n.º 2
0
        /// <inheritdoc />
        public Ticket SellTicket(Seat seat)
        {
            if (seat == null)
            {
                throw new ArgumentNullException("seat");
            }

            if (seat.Session == null)
            {
                throw new ArgumentNullException("seat.Session");
            }

            if (seat.Session.Status == SessionStatus.Closed)
            {
                throw new CinematicException(Messages.SessionIsClosedNoTicketsAvailable);
            }

            if (seat.Session.Status == SessionStatus.Cancelled)
            {
                throw new CinematicException(Messages.SessionIsCancelledNoTicketsAvailable);
            }

            var allocatedSeat = SeatManager.AllocateSeat(seat);

            var newTicket = new Ticket()
            {
                Price       = PriceManager.GetTicketPrice(allocatedSeat.Session, allocatedSeat.Row, allocatedSeat.SeatNumber),
                Seat        = allocatedSeat,
                TimeAndDate = SystemTime.Now()
            };

            DataContext.Add(newTicket);

            return(newTicket);
        }