Ejemplo n.º 1
0
        private static void UpdateVisitorAndParkingLot(SpaceParkContext context)
        {
            var visitorName = StandardMessaging.OutputStringReadUserInput("Name: ");

            Visitor VisitorToPay = Visitor.GetPayingVisitor(context, visitorName);

            Receipt.GetReceipt(VisitorToPay);
            Visitor.ChangePaymentStatus(context, VisitorToPay);
        }
Ejemplo n.º 2
0
        public static void GenerateProgram(SpaceParkContext context)
        {
            string userChoice;

            do
            {
                StandardMessaging.Logo();
                Visitor.ShowCurrentVisitorsList(context);

                StandardMessaging.MenuChoice();
                userChoice = StandardMessaging.OutputStringReadUserInput("=> ");
                Console.Clear();

                ExecuteUserChoice(context, userChoice);
            } while (userChoice != "0");
        }
Ejemplo n.º 3
0
        private static void RentParkingSpace(SpaceParkContext context)
        {
            var parkingSpaces = context.ParkingLots.Where(p => p.ParkingLotOccupied == false).ToList();

            if (parkingSpaces.Count < 1)
            {
                StandardMessaging.ParkingLotFull();
                Console.ReadLine();
                return;
            }

            var currentParkingSpace = parkingSpaces.First();

            StandardMessaging.EnterInformationBelow();
            Console.WriteLine();

            var visitorName = StandardMessaging.OutputStringReadUserInput("Name: ");

            if (visitorName == null || string.IsNullOrWhiteSpace(visitorName))
            {
                return;
            }

            var visitor = DataAPI.EvaluateCharacter(visitorName);

            if (visitor == null)
            {
                return;
            }

            var shipName = StandardMessaging.OutputStringReadUserInput("Ship: ");
            var ship     = DataAPI.EvaluateShips(shipName);

            if (ship == null)
            {
                return;
            }

            Visitor.AddVisitorToDB(context, visitor);
            currentParkingSpace.ParkingLotOccupied = true;
            VisitorParking.AddVisitorParking(context, currentParkingSpace, visitor);
        }
Ejemplo n.º 4
0
        public static void ChangePaymentStatus(SpaceParkContext context, Visitor VisitorToPay)
        {
            if (VisitorToPay.HasPaid == false)
            {
                VisitorToPay.HasPaid = true;

                var parking = VisitorParking.GetSpecificVisitorParking(context, VisitorToPay);

                var parkingLot = ParkingLot.GetSpecificParkingLot(context, parking);
                parkingLot.ParkingLotOccupied = false;

                context.SaveChanges();

                StandardMessaging.ThankYouForYourStay();
                Console.ReadLine();
            }
            else
            {
                StandardMessaging.NoValidInput("Couldn't find you in db. Or something just doesn't work ;)");
            }
        }
Ejemplo n.º 5
0
        private static void ExecuteUserChoice(SpaceParkContext context, string userChoice)
        {
            switch (userChoice)
            {
            case "1":
                RentParkingSpace(context);
                Console.Clear();
                break;

            case "2":
                UpdateVisitorAndParkingLot(context);
                Console.Clear();
                break;

            case "0":
                Environment.Exit(0);
                break;

            default:
                StandardMessaging.NoValidInput("You can only choose from the alternatives. Try again!");
                break;
            }
        }