Exemple #1
0
        static async Task Main(string[] args)
        {
            var context                = new Context();
            var vehicleDataAccess      = new VehicleDataAccess();
            var personDataAccess       = new PersonDataAccess();
            var parkingHouseDataAccess = new ParkingHouseDataAccess();
            var spacePark              = new SpacePark();


            await spacePark.Start();

            //// Tömmer databasen på personer
            //var listOfPeople = await personDataAccess.GetListOfPeopleAsync();
            //foreach (var item in listOfPeople)
            //{
            //    context.Remove(item);
            //    context.SaveChanges();
            //}

            ////Tömmer databasen på starships
            //var listOfShips = await vehicleDataAccess.GetListOfStarShipsAsync();
            //foreach (var item in listOfShips)
            //{
            //    context.Remove(item);
            //    context.SaveChanges();
            //}
        }
Exemple #2
0
 public static bool NewRandomVisit()
 {
     SpacePark.Print("World", "Something approaches the hangar.");
     if (SpacePark.IsThereFreeParkingSpace())
     {
         return(true);
     }
     SpacePark.Print("Guard", "The parking space is full, you have to go to another SpacePort!", true);
     return(false);
 }
Exemple #3
0
        public static void RandomVisitorLeaves()
        {
            int removeIndex = SpacePark.RandomSeed.Next(1, SpacePark.MaxParkingSpaces);

            using (var context = new MyContext())
            {
                var parkingList = context.ParkingSpaces.ToList();
                if (removeIndex <= parkingList.Count)
                {
                    SpacePark.RemoveParkedGuest(removeIndex);
                }
            }
        }
Exemple #4
0
        public static PersonResult AddRandomGeneratedVisitor()
        {
            PersonResult result       = null;
            int          randomNumber = SpacePark.RandomSeed.Next(1, (int)(SpacePark.NumberOfValidNames * 1.15));

            if (randomNumber > SpacePark.NumberOfValidNames)
            {
                SpacePark.Print("Guard", $"You must leave! This is stictly a VIP SpacePort, {GetRandomName()}!", true);
            }
            else
            {
                result = SpacePark.APICall.GetPersonInfoByID(randomNumber).Result;
                //SpacePark.RandomSleepTimer += 5;
                if (result == null)
                {
                    SpacePark.Print("World", "It seems as if SWAPI is unable to respond at the moment.");
                    return(null);
                }
                SpacePark.Print("Guard", $"Welcome {result.Name} to my Spaceport");
            }
            return(result);
        }
Exemple #5
0
 public static void GenerateRandomVisit()
 {
     if (RandomMethods.NewRandomVisit())
     {
         PersonResult visitor = RandomMethods.AddRandomGeneratedVisitor();
         if (visitor != null)
         {
             var starship = GetRandomVehicleOrStarship(visitor);
             if (SpacePark.IsCorrectLength(starship.doubleLength))
             {
                 SpacePark.ParkSpaceship(visitor.Name, starship.Name);
                 SpacePark.Print("Guard", "Your ship is parked.", true);
             }
             else
             {
                 SpacePark.Print("Guard", $"I'm sorry but your spaceship is too big!", true);
             }
         }
         else
         {
             SpacePark.Print("World", "The visitor left.", true);
         }
     }
 }