Beispiel #1
0
        public void DisplaySitesInfo(Campground campground)
        {
            Console.Clear();

            ParkSqlDAL  campSitesDal = new ParkSqlDAL(_dbConnectionString);
            List <Site> sites        = campSitesDal.GetSites(campground.CampgroundId);

            Console.WriteLine();
            Console.WriteLine(" " + campground.CampgroundName + " Camp Site Information");
            Console.WriteLine();
            Console.WriteLine(" {0,0} {1,15} {2,15} {3,15} {4,15}", "Site #", "Max Occupancy", "Accessibility", "Max RV Length", "Utilities");
            Console.WriteLine();

            for (int index = 0; index < sites.Count; index++)
            {
                string siteInfo = sites[index].SiteNumber.ToString() + ") " +
                                  " " + sites[index].MaxOccupancy.ToString().PadLeft(10) +
                                  " " + sites[index].AccessibilityStr.PadLeft(15) +
                                  " " + sites[index].MaxRvLength.ToString().PadLeft(15) +
                                  " " + sites[index].UtilitiesStr.PadLeft(20);

                if (sites[index].SiteNumber <= 9)
                {
                    Console.WriteLine("  " + siteInfo);
                }
                else
                {
                    Console.WriteLine(" " + siteInfo);
                }
            }
        }
Beispiel #2
0
        private void PrintParkInfo()
        {
            ParkSqlDAL  parkDal     = new ParkSqlDAL(connectionString);
            List <Park> parksById   = parkDal.GetAllParksById();
            const int   columnWidth = 21;

            Console.Clear();
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("   " + parksById[selectedParkId - 1].Name + " Park Information:   \n");
            Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine("   Location:".PadRight(columnWidth) + parksById[selectedParkId - 1].Location);
            Console.WriteLine("   Established:".PadRight(columnWidth) + parksById[selectedParkId - 1].Establish_Date.Date.ToString("M/d/yyyy"));
            Console.WriteLine("   Area:".PadRight(columnWidth) + parksById[selectedParkId - 1].Area.ToString("###,###") + " sq km");
            Console.WriteLine("   Visitors:".PadRight(columnWidth) + parksById[selectedParkId - 1].Visitors.ToString("#,###,###") + " Annually\n");

            var words = parksById[selectedParkId - 1].Description.Split(' ');
            var lines = words.Skip(1).Aggregate(words.Take(1).ToList(), (l, w) =>
            {
                if (l.Last().Length + w.Length >= Console.WindowWidth - 1)
                {
                    l.Add(w);
                }
                else
                {
                    l[l.Count - 1] += " " + w;
                }
                return(l);
            });

            foreach (string line in lines)
            {
                Console.WriteLine(line);
            }
            Console.WriteLine();
        }
Beispiel #3
0
        // GET: Home
        public ActionResult Home()
        {
            ParkSqlDAL  dal   = new ParkSqlDAL(connectionString);
            List <Park> parks = dal.GetParks();

            return(View(parks));
        }
Beispiel #4
0
        // Gets a single parks information
        private Park GetPark(int parkId)
        {
            IParkDAL parkdal = new ParkSqlDAL(DatabaseConnectionString.DatabaseString);
            Park     park    = parkdal.GetPark(parkId);

            return(park);
        }
Beispiel #5
0
        private Park DisplayPark(string input)
        {
            Park        selectedPark = null;
            ParkSqlDAL  dal          = new ParkSqlDAL(connectionString);
            List <Park> parkInfo     = dal.GetAllParks();
            bool        parsed       = int.TryParse(input, out int selection);

            if (parsed)
            {
                if (selection <= parkInfo.Count() && selection != 0)
                {
                    selectedPark = parkInfo[selection - 1];
                    Console.WriteLine(selectedPark.ToString());
                    return(selectedPark);
                }
                else
                {
                    Console.Write("The park number you have selected is invalid, ");
                }
            }
            else
            {
                Console.Write("Please enter a park number or ");
            }
            return(selectedPark);
        }
Beispiel #6
0
        public void ParkHasList()
        {
            ParkSqlDAL parkSql = new ParkSqlDAL();

            output = parkSql.ListAllParks();
            Assert.IsNotNull(output);
        }
            public void ReturnAllParksInData()
            {
                ParkSqlDAL  testPark = new ParkSqlDAL(connectionString);
                List <Park> testList = testPark.AllParks();

                Assert.AreEqual(4, testList.Count);
            }
Beispiel #8
0
        public ActionResult Detail(string id)
        {
            if (id == null)
            {
                id = "CVNP";
            }
            ParkSqlDAL ParkSql = new ParkSqlDAL(connectionString);



            var tempValue = Session["tempValue"];

            if (tempValue == null)
            {
                tempValue = 0;
            }
            WeatherSqlDAL sqlweather = new WeatherSqlDAL(connectionString);
            ParkModel     park       = ParkSql.SelectedParkDecriptiveDetails(id);

            park.WeatherList = sqlweather.SpecificParkWeather(id);

            Session["tempValue"]   = tempValue;
            park.TempValueProperty = (int)tempValue;

            ViewBag.WeatherData = park.WeatherList;

            return(View("Detail", park));
        }
Beispiel #9
0
        private void ViewParkCampgrounds()
        {
            ParkSqlDAL  dal   = new ParkSqlDAL(DatabaseConnection);
            List <Park> parks = dal.SeeParks();

            Console.WriteLine("Which park would you like to choose?");
            if (parks.Count > 0)
            {
                for (int i = 0; i < parks.Count; i++)
                {
                    Console.WriteLine((i + 1).ToString().PadRight(10) + parks[i].Name);
                }
            }
            int parsedUserInput = 0;

            while (parsedUserInput <= 0 || parsedUserInput > parks.Count)
            {
                string userInput = Console.ReadLine();
                Int32.TryParse(userInput, out parsedUserInput);
                if (parsedUserInput <= 0 || parsedUserInput > parks.Count)
                {
                    Console.WriteLine("Please enter a valid number");
                }
            }

            Park      userPark = parks[parsedUserInput - 1];
            SubCLIOne submenu  = new SubCLIOne();

            submenu.Display(userPark);
        }
Beispiel #10
0
        private void DisplayReservationConfirmation(int result)
        {
            string command = menus.ConfirmationMenu();

            ParkSqlDAL reservationDal = new ParkSqlDAL(_dbConnectionString);

            bool exit = false;

            while (!exit)
            {
                if (command == "R" || command == "r")
                {
                    DisplayReservationDetails(result);
                }
                else if (command == "M" || command == "m")
                {
                    DisplayMenu();
                }
                else if (command == "Q" || command == "q")
                {
                    menus.QuitMenu();
                    exit = true;
                }
                else
                {
                    menus.InvalidEntry();
                }

                Console.ReadKey();
                Console.Clear();
            }
        }
Beispiel #11
0
        // GET: Home
        public ActionResult Index()
        {
            ParkSqlDAL  parkDAL  = new ParkSqlDAL(connectionString);
            List <Park> parkList = parkDAL.GetParks();

            return(View("Index", parkList));
        }
        private void ShowAllNationalParks()
        {
            Console.WriteLine("Showing Parks");

            ParkSqlDAL dal = new ParkSqlDAL(connectionString);

            List <Park> allParks = dal.GetAllParks();

            foreach (Park p in allParks)
            {
                Console.WriteLine();
                Console.WriteLine("Park ID: " + p.Park_id);
                Console.WriteLine("Park Name: " + p.Name);
                Console.WriteLine("Park Location:" + p.Location);
                Console.WriteLine("Date of Park Establishment: " + p.Establish_date);
                Console.WriteLine("Park Size: " + p.Area);
                Console.WriteLine("Number of vistors in Park: " + p.Vistitors);
                Console.WriteLine("Description of Park: " + p.Description);
            }

            Console.WriteLine();
            Console.WriteLine("Would you Like to see a Parks campgrounds(Y/N)?");
            string input = Console.ReadLine().ToUpper();

            if (input == "Y")
            {
                int userInputParkId = CLIHelper.GetInteger("Please enter a Park Id");

                ShowAllCampgroundInAPark(userInputParkId);
            }
            return;
        }
        public void TestCampgroundList()
        {
            TransactionScope test = new TransactionScope();

            ParkSqlDAL  parkDAL = new ParkSqlDAL(connectionString);
            List <Park> park    = parkDAL.GetParks();

            CampgroundSqlDAL campgroundDAL = new CampgroundSqlDAL(connectionString);

            List <Campground> testNumberOfCampsAcadia         = campgroundDAL.GetAllCampgroundFromPark(park[0]);
            List <Campground> testNumberOfCampsArches         = campgroundDAL.GetAllCampgroundFromPark(park[1]);
            List <Campground> testNumberOfCampsCuyahogaValley = campgroundDAL.GetAllCampgroundFromPark(park[2]);

            //assert
            bool outputAcadia_doesCampCountNumberMatch = testNumberOfCampsAcadia.Count == 3;

            Assert.IsTrue(outputAcadia_doesCampCountNumberMatch);

            bool outputArches_doesCampCountNumberMatch = testNumberOfCampsArches.Count == 3;

            Assert.IsTrue(outputArches_doesCampCountNumberMatch);

            bool outputCuyahogaValley_doesCampCountNumberMatch = testNumberOfCampsCuyahogaValley.Count == 1;

            Assert.IsTrue(outputCuyahogaValley_doesCampCountNumberMatch);

            test.Dispose();
        }
Beispiel #14
0
        private void DisplayReservationDetails(int reservationId)
        {
            Console.Clear();

            ParkSqlDAL         reservationDal       = new ParkSqlDAL(_dbConnectionString);
            List <Reservation> confirmedReservation = reservationDal.GetConfirmedReservationInfo(reservationId);

            Console.WriteLine();

            bool exit = false;

            while (!exit)
            {
                string command = menus.ConfirmedReservationDetails(confirmedReservation);

                if (command == "M" || command == "m")
                {
                    DisplayMenu();
                }
                else if (command == "Q" || command == "q")
                {
                    menus.QuitMenu();
                }
                else
                {
                    menus.InvalidEntry();
                    exit = true;
                }

                Console.ReadKey();
                Console.Clear();
            }
        }
Beispiel #15
0
        // GET: Home
        public ActionResult Index()
        {
            ParkSqlDAL       sql     = new ParkSqlDAL(connectionString);
            List <ParkModel> newList = sql.NationalParksList();

            return(View(newList));
        }
        //Get: ParkInterface
        public ActionResult ParkInterface(int id)
        {
            ParkSqlDAL parkDAL = new ParkSqlDAL(connectionString);
            Park       park    = parkDAL.GenerateParkName(id);

            return(View("ParkInterface", park));
        }
Beispiel #17
0
        public void TestParkNames()
        {
            TransactionScope testParkNames;

            testParkNames = new TransactionScope();
            ParkSqlDAL  parkDAL = new ParkSqlDAL(connectionString);
            List <Park> park    = parkDAL.GetParks();

            string park_1_Name = "Acadia";
            string park_2_Name = "Arches";
            string park_3_Name = "Cuyahoga Valley";

            bool output_Name_Matches1 = park[0].name == park_1_Name;

            Assert.IsTrue(output_Name_Matches1);

            bool output_Name_Matches2 = park[1].name == park_2_Name;

            Assert.IsTrue(output_Name_Matches2);

            bool output_Name_Matches3 = park[2].name == park_3_Name;

            Assert.IsTrue(output_Name_Matches3);

            testParkNames.Dispose();
        }
Beispiel #18
0
        public void PrintParkCampGround(int parkSelection)
        {
            Console.Clear();
            CampGroundSqlDAL  campGroundsinPark = new CampGroundSqlDAL(databaseconnectionString);
            ParkSqlDAL        park             = new ParkSqlDAL(databaseconnectionString);
            List <Campground> printCampGrounds = new List <Campground>();

            try
            {
                printCampGrounds = campGroundsinPark.GetParkCampGround(park.GetParkID(parkSelection));
            }
            catch (SqlException ex)
            {
                Console.WriteLine("Invalid input. Please try again.");
                return;
            }
            Console.WriteLine("\tName".PadRight(35) + "Open".PadRight(13) + "Close".PadRight(13) + "Daily Fee");
            int count = 0;

            foreach (Campground campground in printCampGrounds)
            {
                Console.WriteLine($"#{count + 1} \t{printCampGrounds[count].ToString()}");
                count++;
            }
            CampGroundView(parkSelection);
        }
Beispiel #19
0
        /// <summary>
        /// Display the list of parks
        /// </summary>
        /// <returns>The park id selected by user</returns>
        private int DisplayAllParks()
        {
            int parkSelection = 0;

            while (true)
            {
                ParkSqlDAL   dal   = new ParkSqlDAL(DatabaseConnection);
                IList <Park> parks = dal.GetParks();


                if (parks.Count > 0)
                {
                    Console.WriteLine("Please select the national park that you wish to visit.");
                    foreach (Park park in parks)
                    {
                        Console.WriteLine(park.ParkId.ToString().PadRight(10) + park.Name.PadRight(40));
                    }
                    Console.Write(">>  ");
                    parkSelection = CLIHelper.GetInteger(Console.ReadLine());
                    if (parkSelection <= parks.Count && parkSelection > 0)
                    {
                        break;
                    }
                    Console.Clear();
                }
                else
                {
                    Console.WriteLine("**** SOLD TO PRIVATE CORPORATION-TEDDY ROOSEVELT SPINNING IN GRAVE ****");
                }
            }
            return(parkSelection);
        }
Beispiel #20
0
        public static int GetParkInteger(string message, string connectionString)
        {
            string userInput        = String.Empty;
            int    intValue         = 0;
            int    numberOfAttempts = 0;

            ParkSqlDAL  parkDal           = new ParkSqlDAL(connectionString);
            List <Park> parksAlphabetical = parkDal.GetAlphabeticalListOfAllParks();

            do
            {
                if (numberOfAttempts > 0)
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("   Invalid input format. Please try again\n");
                    Console.ForegroundColor = ConsoleColor.White;
                }
                Console.ForegroundColor = ConsoleColor.DarkGreen;
                Console.Write(message);
                Console.ForegroundColor = ConsoleColor.White;
                userInput = Console.ReadLine();
                numberOfAttempts++;
                Console.WriteLine();
            }while (!int.TryParse(userInput, out intValue) || intValue > parksAlphabetical.Count);

            return(intValue);
        }
Beispiel #21
0
        public ActionResult Weather(string id)
        {
            IParkDAL       DAL      = new ParkSqlDAL();
            List <Park>    ParkList = DAL.getAllParksData();
            List <Weather> weather  = new List <Weather>();

            foreach (Park p in ParkList)
            {
                if (id == p.ParkCode)
                {
                    IWeatherDAL thisDAL = new WeatherSqlDAL();
                    weather = thisDAL.getWeatherByParkCode(p.ParkCode);
                }
            }

            bool isFaranheight;

            Session["Tempature"] = Request.Params["Tempature"];
            if (Session["Tempature"] != null)
            {
                if (Session["Tempature"].ToString() == "F")
                {
                    isFaranheight = true;
                }
                else
                {
                    isFaranheight = false;
                }
            }
            else
            {
                isFaranheight = true;
            }
            // update to Faranheight or Celcius
            for (int i = 0; i < weather.Count; i++)
            {
                if (isFaranheight)
                {
                    if (weather[i].Tempature == "F")
                    {
                        continue;
                    }
                    else
                    {
                        weather[i].Tempature = "F";
                        weather[i].High      = ChangeFaranheightToCelcius(weather[i].High, "F");
                        weather[i].Low       = ChangeFaranheightToCelcius(weather[i].Low, "F");
                    }
                }
                else
                {
                    weather[i].Tempature = "C";
                    weather[i].High      = ChangeFaranheightToCelcius(weather[i].High, "C");
                    weather[i].Low       = ChangeFaranheightToCelcius(weather[i].Low, "C");
                }
            }

            return(View("Weather", weather));
        }
        public void GetParkByIdTest()
        {
            ParkSqlDAL parkSqlDAL = new ParkSqlDAL(connectionString);

            Park park = parkSqlDAL.GetParkById("AAA");

            Assert.AreEqual("AAA", park.ParkCode);
        }
        public void GetAllParksTest()
        {
            ParkSqlDAL parkSqlDAL = new ParkSqlDAL(connectionString);

            List <Park> parks = parkSqlDAL.GetAllParks();

            Assert.IsNotNull(parks);
        }
Beispiel #24
0
        // GET: Home/Parklist
        public ActionResult ParkList()
        {
            Session["ParkList"] = "active";
            IParkDAL    DAL   = new ParkSqlDAL();
            List <Park> model = DAL.getAllParksData();

            return(View("ParkList", model));
        }
        public void GetParkInfoTest()
        {
            ParkSqlDAL dal = new ParkSqlDAL(ConnectionString);

            var park = dal.GetParkInfo(1);

            Assert.AreEqual("Test Park", park.Name);
        }
        public void GetParksTest()
        {
            ParkSqlDAL dal = new ParkSqlDAL(ConnectionString);

            var park = dal.GetParks();

            Assert.AreEqual(1, park.Count);
        }
        public void GetAllParksTest()
        {
            ParkSqlDAL  parkDAL  = new ParkSqlDAL(connectionString);
            List <Park> parkList = parkDAL.GetAllParks();

            Assert.IsNotNull(parkList);
            Assert.AreEqual(parks, parkList.Count);
        }
Beispiel #28
0
        public void GetAllParksTest()
        {
            ParkSqlDAL  sqlDAL = new ParkSqlDAL(connectionString);
            List <Park> park   = sqlDAL.GetAllParks();

            Assert.IsNotNull(park);
            Assert.AreEqual(numParks + 1, park.Count);
        }
Beispiel #29
0
        public void ParkSqlDalTests()
        {
            ParkSqlDAL parkDal = new ParkSqlDAL(connectionString);

            List <Park> parks = parkDal.GetParks();

            Assert.IsNotNull(parks);
        }
        // GET: Home
        public ActionResult Index()
        {
            ParkSqlDAL dal = new ParkSqlDAL(connectionString);

            List <Park> allParks = dal.GetAllParkData();

            return(View("Index", allParks));
        }