private List <Site> GetAvailableSites(Campground selectedCampground, List <int> bookedSiteIds)
        {
            //assemble list of sites in campground from database
            //if a site's ID is NOT in the list of booked site IDs, it is added to list of *available sites*

            SiteDAL     dal = new SiteDAL(DatabaseConnection);
            List <Site> allSitesInCampground = dal.AllSitesInCampground(selectedCampground.CampgroundId);

            List <Site> availableSites = new List <Site>();

            foreach (Site thisSite in allSitesInCampground)
            {
                bool booked = false;
                foreach (int bookedId in bookedSiteIds)
                {
                    if (thisSite.SiteId == bookedId)
                    {
                        booked = true;
                    }
                }
                if (booked == false)
                {
                    availableSites.Add(thisSite);
                }
            }
            return(availableSites);
        }
Esempio n. 2
0
        public void AllSitesInCampgroundTest()
        {
            SiteDAL siteDal      = new SiteDAL(connectionString);
            int     campGroundId = 1;

            List <Site> sites = siteDal.AllSitesInCampground(campGroundId);

            Assert.AreEqual(numberOfSites + 1, sites.Count);
        }