Пример #1
0
        // LEVEL: CAMPGROUNDS /////////////////////////////////////////
        private int[] GetAllCampgrounds_View(int parkID)
        {
            CampgroundSqlDAL dal = new CampgroundSqlDAL(DatabaseConnection);

            Console.WriteLine(
                " ".PadRight(10)
                + "Name".PadRight(40)
                + "Open".PadRight(15)
                + "Close".PadRight(15)
                + "Daily Fee".PadLeft(15));

            IList <Campground> campgrounds = dal.GetCampgroundsFromPark(parkID);

            if (campgrounds.Count > 0)
            {
                int[] output = new int[campgrounds.Count];
                int   i      = 0;
                foreach (Campground campground in campgrounds)
                {
                    this.PrintCampground(campground.Campground_Id, campground.Name, campground.Opening_Month, campground.Closing_Month, campground.Daily_Fee);
                    output[i] = campground.Campground_Id;
                    i++;
                }

                return(output);
            }
            else
            {
                Console.WriteLine("**** NO RESULTS ****");
                return(new int[0]);
            }
        }
Пример #2
0
        public void GetCampgroundsFromPark_ReturnsCampgrounds()
        {
            // Arrange
            CampgroundSqlDAL dal = new CampgroundSqlDAL(ConnectionString);

            int ID = 0;

            using (SqlConnection conn = new SqlConnection(ConnectionString))
            {
                conn.Open();
                SqlCommand    command = new SqlCommand("SELECT park_id FROM park", conn);
                SqlDataReader reader  = command.ExecuteReader();
                while (reader.Read())
                {
                    ID = Convert.ToInt32(reader["park_id"]);
                }
            }

            // Act
            Campground         test        = new Campground();
            IList <Campground> campgrounds = dal.GetCampgroundsFromPark(ID);


            // Assert
            Assert.AreEqual(1, campgrounds.Count);
        }
Пример #3
0
        private void GetParkAvailability_View()
        {
            // ParkAvailability
            DateTime startDate = CLIHelper.GetDateTime("What is the arrival date? mm/dd/yyyy");
            DateTime endDate   = CLIHelper.GetDateTime("What is the departure date? mm/dd/yyyy");

            ParkSqlDAL       parkDAL            = new ParkSqlDAL(DatabaseConnection);
            IList <Campsite> availableCampsites = parkDAL.ParkAvailability(this.ChosenParkID, startDate, endDate);
            int lengthOfStay = (int)(endDate - startDate).TotalDays;

            CampgroundSqlDAL campgroundDAL = new CampgroundSqlDAL(DatabaseConnection);

            IList <Campground>           campgroundsList = campgroundDAL.GetCampgroundsFromPark(this.ChosenParkID);
            Dictionary <int, Campground> campgroundDict  = this.ListToDict(campgroundsList);

            if (availableCampsites.Count > 0)
            {
                decimal cost = 0;
                decimal fee  = 0;
                Console.WriteLine(
                    "Campground".PadRight(30)
                    + "Site No.".PadRight(15)
                    + "Max Occup.".ToString().PadRight(15)
                    + "Accessible".PadRight(15)
                    + "RV Len".PadRight(15)
                    + "Utility".PadRight(15)
                    + "Cost".PadLeft(20));

                foreach (Campsite campsite in availableCampsites)
                {
                    fee  = campgroundDict[campsite.Campground_Id].Daily_Fee;
                    cost = fee * lengthOfStay;
                    this.PrintCampsiteAvailability(
                        campgroundDict[campsite.Campground_Id].Name,
                        campsite.Site_Number,
                        campsite.Max_Occupancy,
                        campsite.IsAccessible,
                        campsite.Max_RV_Length,
                        campsite.HasUtilities,
                        cost);
                }
            }
            else
            {
                Console.WriteLine("**** NO RESULTS ****");
            }
        }