Пример #1
0
 public bool employeeLogin(bool logout)
 {
     try {
         InventoryService inventoryService = new InventoryServiceImpl();
         string           choice;
         while (!logout)
         {
             Console.WriteLine("Hello employee. These are requests you must process. \n");
             InventoryServiceImpl.printRequests();
             Console.WriteLine(" - Back to login [b]");
             choice = inputService.pickRequestsToProcessConsoleRead();
             if (choice.Equals("b"))
             {
                 logout = true;
             }
             else
             {
                 Request request = InventoryService.requests[Int16.Parse(choice)];
                 inventoryService.updateRequest(request);
             }
         }
         return(true);
     }
     catch (Exception e)
     {
         return(false);
     }
 }
Пример #2
0
        public bool userBookingSelectInterface(Boolean existingUser, Boolean logout, Boolean bookAgain,
                                               Boolean confirm, UserData employee,
                                               InventoryService inventoryService,
                                               TransactionService transactionService, NotificationService notificationService,
                                               Ticket ticket, Route newRoute, UserData newUser)
        {
            try {
                string choice = "";
                while (!bookAgain)
                {
                    Console.WriteLine("Hello, " + newUser.Name + " you may edit your current bookings:" + " \n");
                    // Print - Ticket Number , Source, Destination, Status
                    InventoryServiceImpl.printAllTickets();
                    Console.WriteLine("Update which ticket?: ");
                    choice = inputService.pickTicketListConsoleRead();
                    ticket = InventoryService.tickets[Int16.Parse(choice)];
                    Console.WriteLine("Edit Ticket " + ticket.TicketNumber + "\n");
                    Console.WriteLine(" - Change Seating [1]");
                    Console.WriteLine(" - Cancel Ticket [2]");
                    Console.WriteLine(" - Back to Login [3]");

                    choice = inputService.pickRequestOptionConsoleRead();
                    switch (Int16.Parse(choice))
                    {
                    case 1:
                        // Create request to update the seating
                        inventoryService.printAvaliableSeats(newRoute);
                        choice = inputService.pickNewSeatingConsoleRead();
                        string oldSeat = ticket.Seat;
                        ticket.Seat   = newRoute.seats[Int16.Parse(choice)];
                        ticket.status = Ticket.Status.Pending;
                        newRoute.seats.RemoveAt(Int16.Parse(choice));
                        newRoute.seats.Add(oldSeat);
                        inventoryService.createRequest(new Request(ticket));
                        Console.WriteLine("Request to change seat created.");
                        break;

                    case 2:
                        ticket.status = Ticket.Status.Canceled;
                        inventoryService.createRequest(new Request(ticket));
                        Console.WriteLine("Request to Cancel ticket created.");
                        break;

                    case 3:
                        bookAgain = true;
                        logout    = true;
                        break;

                    default:
                        break;
                    }
                }
            } catch (Exception e)
            {
                return(false);
            }
            return(logout);
        }
Пример #3
0
        static void Main(string[] args)
        {
            string choice;

            while (true)
            {
                Console.WriteLine("Welcome to Theta Airlines. Guess you'd like to go on a plane ride, huh? Well where would you like to go? \n");
                Console.WriteLine("You can go to: \n");
                // Should have a call that sees all available addresses
                // Then assumes city you're coming from? If new user ask for that?
                // Then pick avaliable route given destination.
                // Pick seat then payment information.
                InventoryServiceImpl.getAllAvaliableRoutes();
                Console.WriteLine("Input: ");
                choice = Console.ReadLine();
                Ticket ticket = new Ticket();
            }
        }
Пример #4
0
        public double transactionInterface(Boolean existingUser, Boolean logout, Boolean bookAgain,
                                           Boolean confirm, UserData employee,
                                           InventoryService inventoryService,
                                           TransactionService transactionService, NotificationService notificationService,
                                           Ticket ticket, Route newRoute, UserData newUser)
        {
            try {
                string choice = "";
                if ((existingUser && Int16.Parse(choice) == 2) || !existingUser)
                {
                    Console.WriteLine("\nYou can go to: \n");

                    // Print avaliable locations and object that holds them
                    InventoryServiceImpl.printAllAvaliableLocations();

                    // Ask user for their address information
                    Console.WriteLine("\nInput: \n");
                    choice = inputService.pickDestinationConsoleRead();
                    Location destination = InventoryServiceImpl.getAllAvaliableLocations()[Int16.Parse(choice)];
                    InventoryServiceImpl.getAllAvaliableLocations().RemoveAt(Int16.Parse(choice));
                    newRoute = new Route(destination);
                    Console.WriteLine("Where are you coming from?");
                    Console.WriteLine("State: ");
                    choice = inputService.pickUserStateConsoleRead();
                    Location source = new Location(choice);
                    Console.WriteLine("City: ");
                    choice      = inputService.pickUserCityConsoleRead();
                    source.City = choice;

                    // Initialize Ticket
                    newRoute.Source     = source;
                    ticket.User         = newUser;
                    ticket.Route        = newRoute;
                    ticket.TicketNumber = ticketNumber++;

                    // Seat Information
                    // Say avaliable seats
                    inventoryService.printAvaliableSeats(newRoute);
                    choice      = inputService.integerConsoleRead();
                    ticket.Seat = newRoute.seats[Int16.Parse(choice)];
                    newRoute.seats.RemoveAt(Int16.Parse(choice));

                    // Calculate Price given information
                    ticket.Price = inventoryService.calculatePrice(ticket);

                    // Tell user all Ticket information
                    ticket.toString();

                    Console.WriteLine("\nIs this information correct? \n");
                    Console.WriteLine("- Confirm [1] ");
                    Console.WriteLine("- Deny [2] \n");
                    choice = inputService.pickConfirmDenyConsoleRead();

                    switch (Int16.Parse(choice))
                    {
                    case 1:
                        Console.WriteLine("A transaction will be created for you to purchase this flight. \n");
                        confirm = true;
                        break;

                    case 2:
                        break;

                    default:
                        Console.WriteLine("Neither are an option. \n");
                        break;
                    }

                    // User can now view their ticket so that they may edit it.
                    if (confirm)
                    {
                        // Payment
                        transactionService.createTransaction(ticket);
                        inventoryService.addTicket(ticket);

                        // Ask if want to book another flight
                        notificationService.sendNotification(new Notification(ticket, "Ticket Needs Approval", employee));
                        inventoryService.createRequest(new Request(ticket));

                        Console.WriteLine("Would you like to book another flight? \n");
                        Console.WriteLine(" - Yes [1]");
                        Console.WriteLine(" - No [2] \n");
                        choice = inputService.pickBookAnotherConsoleRead();

                        if (Int16.Parse(choice) == 1)
                        {
                            bookAgain = true;
                        }
                    }
                }
                return(ticket.Price);
            }
            catch (Exception e)
            {
                return(0);
            }
        }