예제 #1
0
        public void SearchByCampId(int campId)
        {
            CampgroundSqlDal             campDal    = new CampgroundSqlDal(dbConnection);
            Dictionary <int, Campground> listOfCamp = campDal.GetNameByCampId(campId);

            Console.WriteLine(@"What is the arrival date? __/__/____ ");
            DateTime fromDate = Convert.ToDateTime(Console.ReadLine());

            Console.WriteLine(@"What is the departure date? __/__/____ ");

            DateTime toDate = Convert.ToDateTime(Console.ReadLine());

            if (fromDate.Month >= listOfCamp[campId].OpenFromMonth && toDate.Month <= listOfCamp[campId].OpenToMonth)
            {
                Console.WriteLine("Results Matching Your Search Criteria\r\n ");
                Console.WriteLine("Camp Name. \t\t Site No.\t Max Occup.\t Accessible?\t RV Len \t Utility\t Cost");

                SearchAvailableSitesByCampId(campId, fromDate, toDate);
                MakeReservation(fromDate, toDate);
            }
            else
            {
                Console.WriteLine(@"Invalid Date(s), park is not open on one of these dates. ");
            }
        }
예제 #2
0
        public void SearchAvailableSitesByCampId(int campId, DateTime fromDate, DateTime toDate)
        {
            TimeSpan totalDays = toDate.Subtract(fromDate);
            int      days      = Convert.ToInt32(totalDays.Days);

            SiteSqlDal  dal = new SiteSqlDal(dbConnection);
            List <Site> listOfAvailableSites = dal.GetAllAvailableSitesForCamp(campId, fromDate, toDate);

            //when working on the bonus search - move this to new method and call it
            CampgroundSqlDal             campDal    = new CampgroundSqlDal(dbConnection);
            Dictionary <int, Campground> listOfCamp = campDal.GetNameByCampId(campId);

            if (listOfAvailableSites.Count > 0)
            {
                for (int i = 0; i < listOfAvailableSites.Count; i++)
                {
                    Console.Write(listOfCamp[campId].Name + "\t\t");
                    Console.Write(listOfAvailableSites[i].SiteNumber + "\t\t");
                    Console.Write(listOfAvailableSites[i].MaxOccupancy + "\t\t");
                    if (listOfAvailableSites[i].Accessible)
                    {
                        Console.Write("Yes\t\t");
                    }
                    else
                    {
                        Console.Write("No\t\t");
                    }
                    if (listOfAvailableSites[i].MaxRVLength == 0)
                    {
                        Console.Write("N/A\t\t");
                    }
                    else
                    {
                        Console.Write(listOfAvailableSites[i].MaxRVLength + " \t\t");
                    }
                    if (listOfAvailableSites[i].Utilities)
                    {
                        Console.Write("Yes\t\t");
                    }
                    else
                    {
                        Console.Write("N/A\t\t");
                    }
                    Console.Write(listOfCamp[campId].DailyFee * days);
                    Console.WriteLine();
                }
            }
            else
            {
                Console.WriteLine("Sorry there are no available sites for your requested dates.");
            }
        }