예제 #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();
            //}
        }
예제 #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);
 }
예제 #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);
                }
            }
        }
예제 #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);
        }
예제 #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);
         }
     }
 }