Пример #1
0
        /// <summary>
        /// Cheks if the customer already has a ticket for this flight if not,
        /// Adds a ticket on his Id to the data base and return the ticket.
        /// </summary>
        /// <param name="token"></param>
        /// <param name="flight"></param>
        /// <returns></returns>
        public Ticket PurchaseTicket(LoginToken <Customer> token, Flight flight)
        {
            Ticket ticket = _customerDAO.CheckIfCustomerHasCardForThisFlight(flight, token.User.Id);

            if (ticket != null)
            {
                throw new TheCustomerHasAlreadyATicketForThisFlightException($"The customer Id: {token.User.Id} has already a ticket for flight: {flight.Id}");
            }
            else
            {
                if (flight.RemainingTickets > 1)
                {
                    flight.RemainingTickets = flight.RemainingTickets - 1;
                    _flightDAO.Update(flight);
                    Ticket newTicket = new Ticket(flight.Id, token.User.Id);
                    _ticketDAO.Add(newTicket);
                    return(newTicket);
                }
                else
                {
                    throw new OutOfTicketsException($"Out of tickets to flight: {flight.Id}");
                }
            }
        }
Пример #2
0
 /// <summary>
 /// Changes the details of the airline company.
 /// </summary>
 /// <param name="token"></param>
 /// <param name="airline"></param>
 public void UpdateAirlineDetails(LoginToken <Administrator> token, AirlineCompany airline)
 {
     _airlineDAO.Update(airline);
 }
Пример #3
0
 /// <summary>
 /// Changes the details of the customer.
 /// </summary>
 /// <param name="token"></param>
 /// <param name="customer"></param>
 public void UpdateCustomerDetails(LoginToken <Administrator> token, Customer customer)
 {
     _customerDAO.Update(customer);
 }
Пример #4
0
 /// <summary>
 /// Removes a ailine company from the data base.
 /// </summary>
 /// <param name="token"></param>
 /// <param name="airline"></param>
 public void RemoveAirline(LoginToken <Administrator> token, AirlineCompany airline)
 {
     _airlineDAO.Remove(airline);
 }
Пример #5
0
 /// <summary>
 /// Removes a customer from the data base.
 /// </summary>
 /// <param name="token"></param>
 /// <param name="customer"></param>
 public void RemoveCustomer(LoginToken <Administrator> token, Customer customer)
 {
     _customerDAO.Remove(customer);
 }
Пример #6
0
 /// <summary>
 /// Get customer by Id
 /// </summary>
 /// <param name="token"></param>
 /// <param name="id"></param>
 /// <returns></returns>
 public Customer GetCustomerById(LoginToken <Administrator> token, long id)
 {
     return(_customerDAO.Get(id));
 }
Пример #7
0
 /// <summary>
 /// Adds a Customer to the data base.
 /// </summary>
 /// <param name="token"></param>
 /// <param name="customer"></param>
 public void CreateNewCustomer(LoginToken <Administrator> token, Customer customer)
 {
     _customerDAO.Add(customer);
 }
Пример #8
0
        /// <summary>
        /// Adds a airline company to the data base.
        /// </summary>
        /// <param name="token"></param>
        /// <param name="airline"></param>
        public AirlineCompany CreateNewAirline(LoginToken <Administrator> token, AirlineCompany airline)
        {
            AirlineCompany airlineCompany = _airlineDAO.Add(airline);

            return(airlineCompany);
        }
 public Customer GetCustomerByUsername(LoginToken <Administrator> token, string username)
 {
     return(_customerDAO.GetCustomerByUserName(username));
 }
 public AirlineCompany GetAirlineByUsername(LoginToken <Administrator> token, string username)
 {
     return(_airlineDAO.GetAirlineByUserName(username));
 }