public async Task <Parkingspot> GetAvailableParkingspot(int spaceportId, int spaceshipLength)
        {
            _logger.LogInformation($"Fetching available parkingspot from the spaceport.");

            var parkingspot = await _context.Parkingspot
                              .Where(z => z.ParkedSpaceship == null && Parkingspot.SpaceshipFits(spaceshipLength) && z.SpaceportId == spaceportId)
                              .FirstOrDefaultAsync();

            return(parkingspot);
        }
예제 #2
0
        public void SpaceshipFits_SameSize_True()
        {
            var shipFits = Parkingspot.SpaceshipFits(Parkingspot.MaxLength);

            Assert.IsTrue(shipFits);
        }
예제 #3
0
        public void SpaceshipFits_Smaller_True()
        {
            var shipFits = Parkingspot.SpaceshipFits(1);

            Assert.IsTrue(shipFits);
        }
예제 #4
0
        public void SpaceshipFits_TooBig_False()
        {
            var shipFits = Parkingspot.SpaceshipFits(999999999);

            Assert.IsFalse(shipFits);
        }
        public async Task <IList <Parkingspot> > GetAllAvailableParkingspots(int spaceshipLength)
        {
            _logger.LogInformation($"Fetching all available parkingspots");

            var parkingspots = await _context.Parkingspot
                               .Where(parkingspot => parkingspot.ParkedSpaceship == null && Parkingspot.SpaceshipFits(spaceshipLength))
                               .ToListAsync();

            return(parkingspots);
        }