/// <summary> /// The override of ExecuteSelection handles whatever selection was made by the user. /// This is where any business logic is executed. /// </summary> /// <param name="choice">"Key" of the user's menu selection</param> /// <returns></returns> protected override bool ExecuteSelection(string choice) { switch (choice) { case "1": // Do whatever option 1 is int userSelection = CLIMenu.GetInteger("Please Make a reservation"); string userName = CLIMenu.GetString("What is Your Name?"); foreach (Site site in sites) { if (userSelection == site.SiteNumber) { int resId = reservationDao.AddReservation(site.SiteId, userName, site.UserStartTime, site.UserEndTime); Console.WriteLine($"Reservation Confirmed! Your reservation number is {resId}!"); Pause(""); return(true); } } Console.WriteLine("Incorrect Site Number Try again."); Pause(""); return(true); case "2": // Do whatever option 2 is WriteError("When this option is complete, we will exit this submenu by returning false from the ExecuteSelection method."); Pause(""); return(false); } return(true); }
public void AddReservation_adds_a_Line_to_table() { int before = GetRowCount("reservation", Conn); IReservationDAO test = new ReservationSqlDAO(Conn); Reservation testReservation = new Reservation(); testReservation = GenerateTestReservationModel(Conn); test.AddReservation(testReservation.SpaceID, testReservation.NumberOfAttendees, testReservation.StartDate, testReservation.EndDate, testReservation.ReservedFor); int after = GetRowCount("reservation", Conn); Assert.AreEqual(before + 1, after); }
public void AddReservationTest() { //Arrange ReservationSqlDAO reservationSqlDAO = new ReservationSqlDAO(connectionString); string start = "2020-07-10"; string end = "2020-07-13"; Reservations reservation = new Reservations { SiteId = 1, FamilyName = "Jones", StartDate = Convert.ToDateTime(start), EndDate = Convert.ToDateTime(end), CreateDate = DateTime.Now }; //Act int confirmationNumber = reservationSqlDAO.AddReservation(reservation); //Assert Assert.IsTrue(confirmationNumber > 0); }