public void CreateReservation_Test() { using (TransactionScope transaction = new TransactionScope()) { s.CreateReservation(10, fromDate, toDate, "Jimmy Vanetta", connectionString); s.CreateReservation(1, fromDate, toDate, "Jimmy Vanetta", connectionString); int result = s.GetReservationID(10, connectionString); int result2 = s.GetReservationID(1, connectionString); Assert.IsNotNull(result); Assert.IsNotNull(result2); } }
private static void BookReservationByParkMenu(Park park, DateTime arrival, DateTime departure) { PrintTrees(); Console.WriteLine(); PrintMenuDoubleSpaced(new[] { park.Name + " Park" }); Console.WriteLine(); List <Campsite> availableCampsites = parkDAL.BookReservationByPark(arrival, departure, park, connectionString); if (availableCampsites.Count == 0) { Console.Clear(); PrintMenuDoubleSpaced(new[] { "I'm sorry, there are no available dates for your selected visit, please select again..." }); ArrivalDateSelectionMenu(park); } Console.SetCursorPosition((Console.WindowWidth - 80) / 2, Console.CursorTop); Console.WriteLine("{0, -15}{1, -15}{2, -15}{3, -15}{4, -15}{5, -15}", $"Site No.", $"Max Occup.", $"Accessible?", $"Max RV Length", $"Utility", $"Cost"); Console.WriteLine(); foreach (var site in availableCampsites) { decimal totalCost = campsiteDAL.CalculateCostOfReservation(site, arrival, departure, connectionString); Console.SetCursorPosition((Console.WindowWidth - 80) / 2, Console.CursorTop); Console.WriteLine("{0, -15}{1, -15}{2, -15}{3, -15}{4, -15}{5, -15}", $"{site.SiteID}", $"{site.MaxOccupancy}", $"{site.Accessible}", $"{site.MaxRvLength}", $"{site.Utilities}", $"{totalCost.ToString("c")}"); } Console.WriteLine(); Campsite reservationSite = new Campsite();//create a new campsite so that the user can book their stay PrintTrees(); int userSelectedSiteID = CLIHelper.GetInteger("What site should be reserved?(To Return to the Main Menu press (0))"); //first verify that the site_id entered exists from the list provided to the user only! bool exists = availableCampsites.Any(x => x.SiteID == userSelectedSiteID); if (userSelectedSiteID == 0) { Console.Clear(); MainMenu(); } else if (exists) { reservationSite.SiteID = userSelectedSiteID; //book a reservation based on the site_id } else { Console.Clear(); Console.WriteLine("That is not a valid option, please select from the choices below..."); BookReservationByParkMenu(park, arrival, departure); } string nameOfReservation = CLIHelper.GetString("What name should the reservation be placed under?"); if (availableCampsites.Any(x => x.SiteID == userSelectedSiteID)) { campsiteDAL.CreateReservation(reservationSite.SiteID, arrival, departure, nameOfReservation, connectionString); Console.WriteLine($"The reservation has been created and the reservation id is " + $"{campsiteDAL.GetReservationID(reservationSite.SiteID, connectionString)}"); Console.WriteLine("Press Enter to Return to the Main Menu"); Console.ReadLine(); MainMenu(); } else { // if the site has not been reserved on the provided dates the reservation will be created Console.WriteLine("This site is already reserved during the dates provided"); BookReservationByParkMenu(park, arrival, departure); } }