// Cancel Ticket From Current Customer.
 public void CancelTicket(LoginToken <Customer> token, Ticket ticket)
 {
     if (UserIsValid(token) && token.User.Id == ticket.Customer_Id)
     {
         if (_flightDAO.GetById((int)ticket.Flight_Id).Departure_Time > DateTime.Now)
         {
             throw new TooLateToCancelTicketException("You Can't Cancel Your Ticket Because The Flight Has Already Begun");
         }
         if (_flightDAO.GetById((int)ticket.Flight_Id).Departure_Time > DateTime.Now.Add(TimeSpan.FromHours(1)))
         {
             throw new TooLateToCancelTicketException("You Can't Cancel Your Ticket One Hour Before The Flight");
         }
         _ticketDAO.Remove(ticket);
     }
 }
예제 #2
0
 public Flight GetFlightById(int id)
 {
     return(_flightDAO.GetById(id));
 }