private void SearchForReservationInterface(Campground selectedCamp) { bool exit = false; while (!exit) { Console.WriteLine("What is the arrival date? "); DateTime arrivalDate = CLIHelper.GetDateTime("Enter in year-month-day format."); Console.WriteLine("What is the departure date?"); DateTime depatureDate = CLIHelper.GetDateTime("Enter in year-month-day format."); SiteDAO dao = new SiteDAO(_connectionString); try { IList <Site> sites = dao.GetTop5Sites(selectedCamp, arrivalDate, depatureDate); if (sites.Count > 0) { Console.Clear(); Console.WriteLine($"Results Matching Your Search Criteria"); Console.WriteLine("Site No.".PadRight(15) + "Max Occup.".PadRight(15) + "Accessible?".PadRight(15) + "Max RV Length".PadRight(15) + "Utility".PadRight(15) + "Cost"); Dictionary <int, Site> siteDict = new Dictionary <int, Site>(); int siteCount = 0; foreach (Site s in sites) { Console.WriteLine($"{++siteCount}) " + $"{s.SiteNumber.ToString().PadRight(15)}" + $"{s.MaxOccupancy.ToString().PadRight(15)}" + $"{s.AccessibleString.PadRight(15)}" + $"{s.MaxRVString.PadRight(15)}" + $"{s.UtilitiesString.PadRight(15)}" + $"{selectedCamp.DailyFee.ToString("C")}"); siteDict.Add(siteCount, s); } Console.WriteLine(); int selection = CLIHelper.GetSingleInteger("Which site should be reserved(enter 0 to cancel) ", 0, sites.Count); Console.WriteLine(); if (selection == 0) { exit = true; } else { //ReservationDAO = new ReservationDAO(_connectionString); string name = CLIHelper.GetString("What name should the reservation be made under? "); MakeReservationInterface(siteDict[selection], name, arrivalDate, depatureDate); exit = true; } } else { Console.Clear(); Console.WriteLine("****** NO RESULTS ******"); Console.WriteLine(""); Console.ReadKey(); exit = true; } } catch { Console.Clear(); Console.WriteLine("Something went wrong with the Dates you entered... try again."); } } }
private void SearchForReservationInterface(Campground selectedCamp) { bool exit = false; SiteDAO dao = new SiteDAO(_connectionString); DateTime arrivalDate; DateTime depatureDate; while (!exit) { try { Console.WriteLine("What is the arrival date? yyyy-mm-dd "); arrivalDate = Convert.ToDateTime(Console.ReadLine()); Console.WriteLine("What is the departure date? yyyy-mm-dd"); depatureDate = Convert.ToDateTime(Console.ReadLine()); if (depatureDate > arrivalDate && (depatureDate - arrivalDate).TotalDays > 0 && arrivalDate > DateTime.Today) { IList <Site> sites = dao.GetTop5Sites(selectedCamp.CampgroundId, arrivalDate, depatureDate); Console.Clear(); Console.WriteLine($"Results Matching Your Search Criteria"); Console.WriteLine("Site No.".PadRight(15) + "Max Occup.".PadRight(15) + "Accessible?".PadRight(15) + "Max RV Length".PadRight(15) + "Utility".PadRight(15) + "Cost"); Dictionary <int, Site> siteDict = new Dictionary <int, Site>(); int siteCount = 0; foreach (Site s in sites) { Console.WriteLine($"{++siteCount}) " + $"{s.SiteNumber.ToString().PadRight(15)}" + $"{s.MaxOccupancy.ToString().PadRight(15)}" + $"{s.AccessibleString.PadRight(15)}" + $"{s.MaxRVString.PadRight(15)}" + $"{s.UtilitiesString.PadRight(15)}" + $"{(selectedCamp.DailyFee * (decimal)(depatureDate - arrivalDate).TotalDays).ToString("C")}"); siteDict.Add(siteCount, s); } Console.WriteLine(); int selection = CLIHelper.GetSingleInteger("Which site should be reserved(enter 0 to cancel) ", 0, sites.Count); Console.WriteLine(); if (selection != 0) { //ReservationDAO = new ReservationDAO(_connectionString); string name = CLIHelper.GetString("What name should the reservation be made under? "); MakeReservationInterface(siteDict[selection], name, arrivalDate, depatureDate); } exit = true; } else { NoResults(exit); } } catch { Console.WriteLine("Something went wrong with the Dates or Name you entered... try again."); } } }