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(); }
private void PrintCampgroundList() { CampgroundSqlDAL campgroundDal = new CampgroundSqlDAL(connectionString); List <Campground> campgrounds = campgroundDal.GetListOfCampgrounds(selectedParkId); ParkSqlDAL parkDal = new ParkSqlDAL(connectionString); List <Park> parksById = parkDal.GetAllParksById(); DateTimeFormatInfo monthName = new DateTimeFormatInfo(); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine($"CAMPGROUNDS AT {parksById[selectedParkId - 1].Name} PARK\n"); Console.ForegroundColor = ConsoleColor.White; Console.WriteLine(" ID".PadRight(6) + "- " + "Name".PadRight(33) + "Open".PadRight(15) + "Close".PadRight(15) + "Daily Fee".PadLeft(10)); for (int i = 0; i < campgrounds.Count; i++) { Console.WriteLine(" " + campgrounds[i].Campground_Id.ToString().PadRight(3) + "- " + campgrounds[i].Name.PadRight(33) + monthName.GetMonthName((campgrounds[i].Open_From_MM)).ToString().PadRight(15) + monthName.GetMonthName((campgrounds[i].Open_To_MM)).ToString().PadRight(15) + ("$" + Math.Round(campgrounds[i].Daily_Fee, 2)).PadLeft(10)); } Console.WriteLine(); }