// 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); } }
public Flight GetFlightById(int id) { return(_flightDAO.GetById(id)); }