public void LeavePark() // Read name and let user select the ship to leave with
        {
            var    parkingCheck = new ParkingChecks();
            var    person       = new PersonApi();
            var    payment      = new PaymentActions();
            string name         = StandardMessages.NameReader();
            var    r            = person.GetAllPersons();

            StandardMessages.LoadingMessage();
            if (r.Result.Any(p => p.Name == name))
            {
                var parkings = parkingCheck.ParkingLots();
                var array    = ArrayBuilder.OnLeaveArray(parkings);
                Console.Clear();
                var selectedOption = Menu.ShowMenu($"Welcome {name}. What ship will you be leaving with today?\n", array);

                if (Occupation.ParkIsOccupied(parkings, selectedOption) == false) // If user selects a empty parking lot, display message
                {
                    StandardMessages.EmptyParkingLotMessage();
                }
                else if (parkings.Result[selectedOption].ParkedBy != name) // If user selects a ship that is not theirs, display message
                {
                    StandardMessages.NotYourShipMessage();
                }
                else
                {
                    payment.Pay(parkings, selectedOption, name); // Pay for the parking lot by getting the database row
                    Leave(parkings, selectedOption);             // Remove ship from database
                }
            }
            else
            {
                StandardMessages.NotAllowedMessage();
            }
        }
 public static bool AllParksOccupied() // Check if all parkings are occupied
 {
     using var context = new SpaceContext();
     StandardMessages.LoadingMessage();
     if (!context.Parkings.All(i => i.Occupied))
     {
         return(false);
     }
     StandardMessages.FullParkMessage();
     return(true);
 }
Exemple #3
0
        public void Park(Starship ship)
        {
            var parkingCheck = new ParkingChecks();

            StandardMessages.LoadingMessage();
            var parkings = parkingCheck.ParkingLots();
            var array    = ArrayBuilder.ParkArray(parkings); // Create string array of all parkings to present to the user in the menu

            Console.Clear();
            var selectedOption = Menu.ShowMenu($"You have selected to park {ship.Name}. Choose parking spot", array);

            Finish(parkings, selectedOption, ship); // Add ship to parking in database
        }
Exemple #4
0
        public void Receipts()
        {
            using var context = new SpaceContext();
            string name     = StandardMessages.NameReader();
            var    payments = context.Payments.Where(p => p.User == name).ToList();

            if (!payments.Any())
            {
                Console.WriteLine("No receipts found.");
            }
            else
            {
                foreach (var r in payments)
                {
                    Console.WriteLine($"Payment By: {r.User}. Amount: {r.Amount} credits. Payment Date: {r.PayDate}");
                }
            }
            Console.ReadKey();
        }
Exemple #5
0
        public static void CreateItemInformation(List <RetailItem> inputList)
        {
            RetailItem thisItem = new RetailItem();

            bool error = false;

            do
            {
                Console.WriteLine(StandardMessages.TheDescription());
                thisItem.Description = Console.ReadLine();

                Console.WriteLine(StandardMessages.TheUnitsOnHand());
                thisItem.UnitsOnHand = ConvertToInt(Console.ReadLine());

                Console.WriteLine(StandardMessages.ThePrice());
                thisItem.Price = ConvertToInt(Console.ReadLine());
            } while (error == true);

            inputList.Add(thisItem);
        }