예제 #1
0
        /// <summary>
        /// In the makeAreservation method we again use the cli helper to take in user input.
        /// It calls the MakeReservation method from the ReservationSqlDAL class and uses it in a list
        /// We created variables of type string in and dateTime to store the user input then we called the reservation class
        /// from the models folder and assigned the user input to the variables in the reservation class which are get; set; properties
        /// We then call the list in a  if statement again and if count of items in list is > 0 we then print out the response with the
        /// reservation id confirming their reservation has been created.
        /// </summary>
        private void MakeAreservation()
        {
            string   name      = CLIHelper.GetString("Please enter the reservation name: ");
            int      site_id   = CLIHelper.GetInteger("Please enter the site number: ");
            DateTime startDate = CLIHelper.GetDateTime("Please enter the arrival date(YYYY/MM/DD): ");
            DateTime endDate   = CLIHelper.GetDateTime("Please enter the departure date(YYYY/MM/DD): ");


            Reservation newRes = new Reservation()
            {
                Name       = name,
                SiteID     = site_id,
                FromDate   = startDate,
                ToDate     = endDate,
                CreateDate = DateTime.Now
            };

            ReservationSqlDAL  dal     = new ReservationSqlDAL(DatabaseConnection);
            List <Reservation> confirm = dal.MakeReservation(newRes);

            if (confirm.Count > 0)
            {
                Console.WriteLine();
                Console.WriteLine("The reservation has been made and the confirmation ID is: " + confirm[0].ReservationId);
            }
            else
            {
                Console.WriteLine("DID NOT MAKE RESERVATION");
            }
        }
예제 #2
0
        public void ReservationConfirmationForPark(string arrivalDate, string departureDate, int camp_id, int parkSelection)
        {
            SiteSqlDAL        site            = new SiteSqlDAL(databaseconnectionString);
            ReservationSqlDAL bookReservation = new ReservationSqlDAL(databaseconnectionString);

            Console.WriteLine();
            Console.Write("Which campground should be reserved? (enter 0 to cancel)  ");
            int campInput = CLI_Helper.GetInteger("==>");

            if (campInput == 0)
            {
                return;
            }

            Console.WriteLine();
            Console.Write("Which camp site should be reserved? (enter 0 to cancel)   ");
            int siteInput = CLI_Helper.GetInteger("==>");

            if (siteInput == 0)
            {
                return;
            }

            Console.WriteLine();
            Console.Write("Under what name should the reservation be held?  ");
            string inputName = Console.ReadLine();

            bookReservation.MakeReservation(parkSelection, site.GetSiteID(siteInput, camp_id), inputName, arrivalDate, departureDate);
            string reservationID = bookReservation.GetReservationId(inputName);

            Thread.Sleep(2000);
            Console.WriteLine();
            Console.WriteLine($"The reservation has been booked and the confirmation ID is: {reservationID}");
            Console.ReadLine();
        }
        private void Reservation(int campgroundId)
        {
            DateTime arrivalInput = CLIHelper.GetDateTime("What is your desired arrival date?(MM/DD/YYYY)");
            DateTime fromDate     = Convert.ToDateTime(arrivalInput);

            DateTime departureInput = CLIHelper.GetDateTime("When would you like to leave?(MM/DD/YYYY)");
            DateTime toDate         = Convert.ToDateTime(departureInput);

            Console.WriteLine("Showing available sites ");

            SiteSqlDAL  sal          = new SiteSqlDAL(connectionString);
            List <Site> allCampSites = sal.CampsiteAvailability(campgroundId, fromDate, toDate);

            if (allCampSites.Count() <= 0)
            {
                Console.WriteLine("No available camp sites! Please make a new selection.");
                return;
            }
            else
            {
                foreach (Site s in allCampSites)
                {
                    Console.WriteLine();
                    Console.WriteLine("SiteId " + s.SiteID);
                    Console.WriteLine("Campground_Id " + s.CampgroundID);
                    Console.WriteLine("SiteNumber " + s.SiteNumber);
                    Console.WriteLine("MaxOccupancy " + s.MaxOccupancy);
                    Console.WriteLine("Handicap Accessible " + s.Accessible);
                    Console.WriteLine("MaxRvLength " + s.MaxRvLength);
                    Console.WriteLine("Utilities are available " + s.Utilities);
                }

                ReservationSqlDAL ral = new ReservationSqlDAL(connectionString);

                campgroundPrice = (ral.CostOfCampground(campgroundId) * (toDate.DayOfYear - fromDate.DayOfYear));

                Console.WriteLine("The total fee for these sites are: " + campgroundPrice.ToString("C"));
                Console.WriteLine();

                int campSiteInput = CLIHelper.GetInteger("What Camp site are you booking for?");
                Console.WriteLine();

                string nameInput = CLIHelper.GetString("What name should the reservation be under?");
                Console.WriteLine();

                DateTime createDate = DateTime.Now;
                int      wasReservationSuccessful = ral.MakeReservations(campSiteInput, nameInput, fromDate, toDate, createDate);

                if (wasReservationSuccessful > 0)
                {
                    Console.WriteLine("Success!");

                    Console.WriteLine("Here is your conformation ID: " + wasReservationSuccessful);
                }
                else
                {
                    Console.WriteLine("Sorry but that site is alreaday booked. Please try again.");
                }
            }
        }
예제 #4
0
        public void AddReservationTest()
        {
            ReservationSqlDAL dal = new ReservationSqlDAL(ConnectionString);

            int initialCount = GetRowCount();

            Reservation reservation = new Reservation();

            reservation.ReservationId = 2;
            reservation.SiteId        = 1;
            reservation.Name          = "Art Vandelay Reservation";
            reservation.StartDate     = new DateTime(2018, 07, 01);
            reservation.EndDate       = new DateTime(2018, 07, 10);
            reservation.CreateDate    = DateTime.Now;

            DateTime[] dateRange = new DateTime[2] {
                reservation.StartDate, reservation.EndDate
            };

            var reservations = dal.AddReservation(reservation.SiteId, reservation.Name, dateRange);

            int finalCount = GetRowCount();

            Assert.AreEqual(initialCount + 1, finalCount);
        }
        public void GetReservationIdTest()
        {
            ReservationSqlDAL reservationtests = new ReservationSqlDAL(dbconnectionString);
            string            testResult       = reservationtests.GetReservationId("TestReservation");

            Assert.AreEqual($"TestReservation_{reservation_idx}", testResult);
        }
        public void CostOfStayTests()
        {
            int     fakePark;
            int     fakeCampground;
            decimal fakeOutput = 2.00M;

            using (SqlConnection conn = new SqlConnection(connectionString))
            {
                conn.Open();
                SqlCommand cmd = new SqlCommand("Insert into Park values ('Big Fake Park', 'FAKE EVERYWHERE', '1919-02-26', 0000, 0, 'THIS IS SO FAKE ITS FUNNY')", conn);
                cmd.ExecuteNonQuery();
                cmd      = new SqlCommand("select cast(scope_identity() as int);", conn);
                fakePark = Convert.ToInt32(cmd.ExecuteScalar());

                string fakeParkString = $"Insert into Campground values ({fakePark}, 'FAKE CAMPGROUND', 1, 12, 2.00)";

                SqlCommand cmd2 = new SqlCommand(fakeParkString, conn);
                cmd2.ExecuteNonQuery();
                cmd            = new SqlCommand("select cast(scope_identity() as int)", conn);
                fakeCampground = Convert.ToInt32(cmd.ExecuteScalar());
            }

            ReservationSqlDAL ral    = new ReservationSqlDAL(connectionString);
            decimal           output = ral.CostOfCampground(fakeCampground);

            Assert.AreEqual(fakeOutput.ToString("C"), output.ToString("C"));
        }
        public void BookReservation(Reservation r)
        {
            string name          = CLIHelper.GetString("Please enter first and last name:");
            int    siteNumber    = CLIHelper.GetInteger("Please enter the site number: ");
            int    numberCampers = CLIHelper.GetInteger("Please enter the number of campers:");

            int reservationID = 0;


            r.Name          = name;
            r.SiteNumber    = siteNumber;
            r.NumberCampers = numberCampers;


            ReservationSqlDAL dal = new ReservationSqlDAL();

            try
            {
                reservationID = dal.BookReservation(r);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            if (reservationID > 0)
            {
                Console.WriteLine($"Your reservation was successfully created. Reservation id: {reservationID}");
            }
            else
            {
                Console.WriteLine("Request unsuccessful. Reservation NOT created.");
            }
        }
예제 #8
0
        public void SearchForParkReservations(string park)
        {
            DateTime          today             = System.DateTime.Now;
            DateTime          futureMonthDate   = today.AddMonths(1);
            ReservationSqlDAL reservationSqlDAL = new ReservationSqlDAL();

            List <Reservation> reservations = new List <Reservation>();

            reservations = reservationSqlDAL.GetParkReversations(park, today, futureMonthDate);

            if (reservations.Count != 0)
            {
                Console.WriteLine($"\nAll Reservations for {park}:");
                Console.WriteLine("ID".PadRight(4) + "Site ID".PadRight(9) + "Name".PadRight(32) + "From Date".PadRight(12) + "To Date");
                foreach (Reservation reservation in reservations)
                {
                    Console.WriteLine(
                        reservation.ReservationId.ToString().PadRight(4) +
                        reservation.SiteID.ToString().PadRight(9) +
                        reservation.Name.ToString().PadRight(32) +
                        reservation.FromDate.ToString("d").PadRight(12) +
                        reservation.ToDate.Date.ToString("d")
                        );
                }

                Console.WriteLine("\nPress <Enter> to continue!");
                Console.ReadLine();
            }
            else
            {
                Console.WriteLine($"No Reservations for {park}");
            }
        }
        public void GetAvailableSites_AdjacentToNext_IsAvailable()
        {
            using (TransactionScope transaction = new TransactionScope())
            {
                // Arrange
                ManualInitialize();
                SiteSqlDAL        testClass         = new SiteSqlDAL(connectionString);
                DateTime          testStartDate     = new DateTime(2000, 6, 10).Date;
                DateTime          testEndDate       = new DateTime(2000, 6, 20).Date;
                DateTime          conflictStartDate = new DateTime(2000, 6, 20).Date;
                DateTime          conflictEndDate   = new DateTime(2000, 6, 30).Date;
                ReservationSqlDAL rDal            = new ReservationSqlDAL(connectionString);
                Reservation       tempReservation = new Reservation();
                tempReservation.Site_Id   = siteId;
                tempReservation.Name      = "TEMP RESERVATION";
                tempReservation.From_Date = conflictStartDate;
                tempReservation.To_Date   = conflictEndDate;
                rDal.AddReservation(tempReservation);

                // Act
                List <Site> availableSites = testClass.GetAvailableSites(testCamp, testStartDate, testEndDate);

                // Assert
                Assert.AreEqual(1, availableSites.Count);
            }
        }
예제 #10
0
        public void MakeNewReservation(string name, int campsiteId, DateTime arrivalDate, DateTime departureDate)
        {
            ReservationSqlDAL reservationSqlDAl = new ReservationSqlDAL();
            int reservationId = reservationSqlDAl.MakeReservation(name, campsiteId, arrivalDate, departureDate);

            Console.WriteLine("The reservation has been made and the confirmation id is {0}", reservationId);
        }
예제 #11
0
        /// <summary>
        /// Select from available sites in selected campground
        /// </summary>
        /// <param name="campground"></param>
        /// <param name="arrival"></param>
        /// <param name="departure"></param>
        private void SiteSelectionMenu(Campground campground, DateTime arrival, DateTime departure)
        {
            Reservation reserve = new Reservation();

            reserve.FromDate = arrival;
            reserve.ToDate   = departure;
            bool quit = false;

            while (!quit)
            {
                SiteSqlDAL  siteSqlDAL = new SiteSqlDAL(_connectionString);
                List <Site> resList    = siteSqlDAL.GetAvailalableSitesInCampground(campground.CampgroundId, arrival, departure);
                TimeSpan    interval   = reserve.ToDate - reserve.FromDate;
                decimal     cost       = interval.Days * campground.DailyFee;

                if (resList.Count == 0)
                {
                    Console.WriteLine("\nNo sites available for the dates provided.");
                }
                else
                {
                    DisplayAvailableSites(resList, cost);

                    reserve.SiteId = 0;
                    int selection = CLIHelper.GetInteger("Which site should be reserved (enter 0 to cancel)?");
                    if (selection < 0)
                    {
                        Console.WriteLine(" Invalid selection. Please try again.");
                    }
                    //else if (selection == 0)
                    //{
                    //    quit = true;
                    //}
                    else if (selection > 0)
                    {
                        //var site = resList.Find(m => m.SiteId == selection);

                        for (int i = 0; i < resList.Count; i++)
                        {
                            if (resList[i].SiteNumber == selection)
                            {
                                reserve.SiteId = resList[i].SiteId;
                            }
                        }
                        if (reserve.SiteId == 0)
                        {
                            Console.WriteLine(" Invalid selection. Please try again.");
                        }
                    }
                    Console.WriteLine("What name Should the reservation be made under?");
                    reserve.Name = Console.ReadLine();
                    ReservationSqlDAL reservationSqlDAL = new ReservationSqlDAL(_connectionString);
                    reserve = reservationSqlDAL.AddReservation(reserve);
                    Console.WriteLine($"The reservation has been made and the confirmation id is {reserve.ReservationId}");

                    quit = true;
                }
            }
        }
예제 #12
0
        /// <summary>
        /// Displays available campsites within a campground based on the user's selection and options
        /// </summary>
        /// <param name="campId"></param>
        /// <param name="arriveDate"></param>
        /// <param name="departDate"></param>
        public void DisplayAvailableSites(int campId, DateTime arriveDate, DateTime departDate)
        {
            SiteSqlDAL  siteDal    = new SiteSqlDAL(DatabaseConnection);
            List <Site> sites      = siteDal.GetCampgroundSites(campId, arriveDate, departDate);
            bool        timeToExit = false;

            while (!timeToExit)
            {
                if (sites.Count == 0)
                {
                    Console.WriteLine("There are no available sites on that date, try again.");
                    Console.ReadKey();
                    Console.Clear();
                    Header();
                    timeToExit = true;
                    //CampgroundReservation(_parks[campId]);
                }
                else
                {
                    int numDays = (int)(departDate - arriveDate).TotalDays + 1;

                    decimal totalCost = _campgrounds[campId - 1].CalculateCost(_campgrounds[campId - 1], numDays);

                    Console.Clear();
                    Header();
                    Console.WriteLine("Results Matching Your Search Criteria");
                    Console.WriteLine();
                    Console.WriteLine($"{siteNo,6} | {maxOcc,9} | {access,9} | {rvLngth,9} | {utility,9} | {cost,9}");
                    for (int i = 0; i < sites.Count; i++)
                    {
                        Console.WriteLine($"{sites[i].SiteNumber,8} | {sites[i].MaxOccupancy,10} | {sites[i].Accessible,11} | {sites[i].MaxRvLength,13} | {sites[i].Utilities,9} | {totalCost.ToString("c"),9}");
                    }  //iterates through the Sites List to display to user

                    Console.WriteLine();
                    int siteId = CLIHelper.GetInteger("Which site would you like to reserve ? (enter 0 to cancel)");
                    if (siteId == 0)
                    {
                        Console.Clear();
                        Header();
                        timeToExit = true;
                    }

                    Console.WriteLine();
                    string resName = CLIHelper.GetString("What name should your reservation be called?");

                    ReservationSqlDAL sqlDal = new ReservationSqlDAL(DatabaseConnection);

                    int resConfirmationId = sqlDal.BookReservation(siteId, arriveDate, departDate, resName);

                    Console.WriteLine();
                    Console.WriteLine($"The reservation has been made and your confirmation number is {resConfirmationId}");
                    Console.WriteLine("Click any key to exit the program.");

                    timeToExit = true;

                    Console.ReadKey();
                }
            }
        }
예제 #13
0
        public void GetReservationsTest()
        {
            ReservationSqlDAL dal = new ReservationSqlDAL(ConnectionString);

            var reservations = dal.GetReservations(1, 1, 1);

            Assert.AreEqual(1, reservations.Count);
        }
예제 #14
0
        //GET: Confirmation
        public ActionResult Confirmation(Reservation reservation)
        {
            ReservationSqlDAL reservationDAL = new ReservationSqlDAL(connectionString);

            int reservationId = reservationDAL.CreateReservation(reservation.SiteID, reservation.ReservationStart, reservation.ReservationEnd, reservation.ReservationName);

            return(View("Confirmation", reservationId));
        }
 public ParkSystem(string connectionString)
 {
     this.ConnectionString = connectionString;
     campgroundDAL         = new CampgroundSqlDAL(ConnectionString);
     campsiteDAL           = new SiteSqlDAL(ConnectionString);
     parkDAL        = new ParkSqlDAL(ConnectionString);
     reservationDAL = new ReservationSqlDAL(ConnectionString);
 }
예제 #16
0
        public void CreatedReservation()  // test that the dictionary item exists
        {
            ReservationSqlDAL reservationSql = new ReservationSqlDAL();
            Reservation       newReservation = new Reservation();


            //output = reservationSql.AddNewReservation(1, "Keet Bailey", DateTime[](2018, 6, 25, 3, 30, 54);
            //Assert.IsNotNull(output);
        }
예제 #17
0
        // LEVEL: RESERVATION  /////////////////////////////////////////
        //
        //
        //
        private int ReserveCampsite_View(int chosenCampsite, DateTime startDate, DateTime endDate, string partyName)
        {
            int reservationID     = 0;
            ReservationSqlDAL dal = new ReservationSqlDAL(DatabaseConnection);

            reservationID = dal.ReserveCampsite(chosenCampsite, startDate, endDate, partyName);

            return(reservationID);
        }
예제 #18
0
        public Dictionary <int, Reservation> AddNewReservation(int siteSelection, string reservationName, DateTime[] reservationRange)
        {
            ReservationSqlDAL             reservationSql = new ReservationSqlDAL();
            Dictionary <int, Reservation> newReservation = new Dictionary <int, Reservation>();

            newReservation = reservationSql.AddNewReservation(siteSelection, reservationName, reservationRange);

            return(newReservation);
        }
예제 #19
0
        public void GetReservationTest()
        {
            ReservationSqlDAL dal = new ReservationSqlDAL(connectionString);

            List <Reservation> list = dal.GetReservation();

            Assert.AreEqual(1, list.Count());
            Assert.AreEqual("Natalie", list[0].name);
        }
예제 #20
0
        public UserInterface(string connectionString)
        {
            this.spaceDAL       = new SpaceSqlDAL(connectionString);
            this.venueDAL       = new VenueSqlDAL(connectionString);
            this.categoryDAL    = new CategorySqlDAL(connectionString);
            this.reservationDAL = new ReservationSqlDAL(connectionString);

            this.cityDAL = new CitySqlDAL(connectionString);
        }
예제 #21
0
        // GET: Index
        public ActionResult Index(CampSearch campSearch)
        {
            ReservationSqlDAL reservationDAL = new ReservationSqlDAL(connectionString);

            Session["CampSearch"] = campSearch;

            List <CampSite> siteList = reservationDAL.FindReservation(campSearch);

            return(View("Index", siteList));
        }
예제 #22
0
        public void ReserveCampsite(int choice, string name, DateTime arrivalDate, DateTime departureDate)
        {
            ReservationSqlDAL reserveDAL = new ReservationSqlDAL(connectionString);

            int reservation_id = reserveDAL.InsertReservation(choice, name, arrivalDate, departureDate);

            Console.WriteLine("\nThe reservation has been made and the confirmation id is {" + reservation_id + "}");
            Console.WriteLine("\nPress ENTER to exit...");
            Console.ReadLine();
        }
예제 #23
0
        public ActionResult ParkScreen(ParkSearch parkSearch)
        {
            ReservationSqlDAL reservationDAL = new ReservationSqlDAL(connectionString);

            Session["ParkSearch"] = parkSearch;

            List <CampSite> siteList = reservationDAL.FindParkReservation(parkSearch);

            return(View("ParkScreen", siteList));
        }
        public void GetParkReservationsTest()
        {
            string             parkName          = "Acadia";
            DateTime           currentDate       = DateTime.MinValue;
            DateTime           futureMonthDate   = DateTime.MinValue;
            ReservationSqlDAL  reservationSqlDAL = new ReservationSqlDAL();
            List <Reservation> result            = reservationSqlDAL.GetParkReversations(parkName, currentDate, futureMonthDate);

            Assert.IsNotNull(result);
        }
        public void AddNewReservation(Reservation reservation)
        {
            IReservationDAL reservationdal = new ReservationSqlDAL(DatabaseConnectionString.DatabaseString);

            (bool worked, int reservationId) = reservationdal.AddNewReservation(reservation);
            if (worked == true)
            {
                Console.WriteLine($"The reservation has been made and the confirmation id is {reservationId}");
            }
        }
        public void CreateReservationTest()
        {
            //Arrange
            ReservationSqlDAL reservationSqlDal = new ReservationSqlDAL(connectionString);

            //Act
            int reservation = reservationSqlDal.CreateReservation(3, today, today, "Test");

            //Assert
            Assert.IsNotNull(reservation);
            Assert.AreEqual(reservation, reservationNumber + 1);
        }
        public void MakeReservationTest()
        {
            int               result;
            string            name              = "Alec2";
            int               campsiteId        = 37;
            DateTime          arrivalDate       = DateTime.Parse("2019-07-04");
            DateTime          departureDate     = DateTime.Parse("2019-07-24");
            ReservationSqlDAL reservationSqlDAL = new ReservationSqlDAL();

            result = reservationSqlDAL.MakeReservation(name, campsiteId, arrivalDate, departureDate);
            Assert.AreEqual(testInsert + 1, result);
        }
        public void SearchForReservationTest()
        {
            string            park              = "Acadia";
            string            campground        = "Blackwoods";
            DateTime          arrivalDate       = DateTime.MinValue;
            DateTime          departureDate     = DateTime.MinValue;
            List <Campsite>   test              = new List <Campsite>();
            ReservationSqlDAL reservationSqlDAL = new ReservationSqlDAL();

            test = reservationSqlDAL.SearchForReservation(park, campground, arrivalDate, departureDate);
            Assert.IsNotNull(test);
        }
        public void SearchForAvailableReservationTest()
        {
            ReservationSqlDAL myDAL = new ReservationSqlDAL(connectionString);

            List <Site> testReservationList = myDAL.SearchForAvailableReservation(siteID, startDate, endDate);

            Assert.AreEqual(testReservationList.Count, 0);

            List <Site> testReservationList2 = myDAL.SearchForAvailableReservation(siteID, Convert.ToDateTime("02/01/2019"), Convert.ToDateTime("02/02/2019"));

            Assert.AreEqual(testReservationList.Count, 1);
        }
예제 #30
0
        private void GetCampsite()
        {
            selectingReservation = true;

            while (selectingReservation)
            {
                Console.WriteLine("Please enter the Campground ID to view the list of available campsites");
                int input = Convert.ToInt32(Console.ReadLine());

                Console.WriteLine("\nWhat date would you like to begin your trip?(Please use format: mm/dd/yyyy)");
                DateTime fromDate = Convert.ToDateTime(Console.ReadLine());

                Console.WriteLine("\nWhat date would you like to end your trip?(Please use format: mm/dd/yyyy)");
                DateTime toDate = Convert.ToDateTime(Console.ReadLine());

                CampsiteSqlDAL  dal       = new CampsiteSqlDAL(DatabaseConnection);
                List <Campsite> campsites = dal.GetCampsite(input, fromDate, toDate);



                if (campsites.Count > 0)
                {
                    campsites.ForEach(c =>
                    {
                        Console.WriteLine(c);
                    });

                    Console.WriteLine("\nPlease select the ID of the site you would like to reserve. If none, select '0'.");
                    int reservationSelection = Convert.ToInt32(Console.ReadLine());

                    if (reservationSelection == 0)
                    {
                        return;
                    }

                    Console.WriteLine("\nWhat name would you like to place the reservation under?");
                    string reservationName = Console.ReadLine();

                    ReservationSqlDAL resDAL = new ReservationSqlDAL(DatabaseConnection);
                    resDAL.MakeReservation(reservationSelection, fromDate, toDate, reservationName);


                    Console.WriteLine("\nConfirmation Code: " + randomHex());


                    selectingReservation = false;
                }
                else
                {
                    Console.WriteLine("\nNo site available.\n");
                }
            }
        }