Esempio n. 1
0
        public void SiteSqlDALGetAllAvailableCampsites()
        {
            using (TransactionScope transaction = new TransactionScope())
            {
                //Arrange
                int        id        = InsertFakeSite();
                SiteSqlDAL testClass = new SiteSqlDAL(connectionString);

                //Act
                List <Site> sites = testClass.GetAllAvailableCampsites("6", DateTime.Now, DateTime.Now);

                //Assert
                Assert.AreEqual(id, sites[sites.Count - 1].Site_Id);
            }
        }
Esempio n. 2
0
        private void DisplaySitesMatchingSearchCriteriaSelectMenu(string campId, DateTime arrivalDate, DateTime departureDate) // Add datetimes for arrival and departure?
        {
            while (true)
            {
                SiteSqlDAL  dal   = new SiteSqlDAL(connectionString);
                SiteSqlDAL  dal2  = new SiteSqlDAL(connectionString);
                List <Site> sites = dal.GetAllAvailableCampsites(campId, arrivalDate, departureDate);
                PrintHeader();
                string accessible;
                string utility;
                int    confirmationID = -1;

                Console.Clear();

                if (sites.Count > 0)
                {
                    Console.WriteLine(("Site No.").PadRight(12) + ("Max Occup.").PadRight(12) + ("Accessible?").PadRight(20) + ("Max RV Length").PadRight(20) + ("Utility").PadRight(12) + ("Cost of Stay").PadRight(12));
                    foreach (Site site in sites)
                    {
                        TimeSpan timeSpan  = departureDate.Subtract(arrivalDate);
                        int      totalDays = (int)timeSpan.TotalDays;
                        decimal  cost      = totalDays * site.Daily_Fee;

                        if (site.Campground_Id.ToString() == campId)
                        {
                            if (site.Accessible)
                            {
                                accessible = "Yes";
                            }
                            else
                            {
                                accessible = "No";
                            }
                            if (site.Utilities)
                            {
                                utility = "Yes";
                            }
                            else
                            {
                                utility = "N/A";
                            }

                            Console.WriteLine(site.Site_Number.ToString().PadRight(12) + site.Max_Occupancy.ToString().PadRight(12) + accessible.PadRight(20) + site.Max_Rv_Length.ToString().PadRight(20) + utility.PadRight(12) + cost.ToString("C").PadRight(12));
                        }
                    }

                    Console.WriteLine();
                    Console.Write("Which site should be reserved (enter 0 to cancel)? ");
                    string userInputSiteId = Console.ReadLine();

                    if (userInputSiteId == "0")
                    {
                        Console.Clear();
                        break;
                    }

                    Console.Write("What name should the reservation be made under?");
                    string userInputName = Console.ReadLine();

                    ReservationSqlDAL dalRes = new ReservationSqlDAL(connectionString);

                    foreach (Site site in sites)
                    {
                        if (userInputSiteId == site.Site_Number.ToString())
                        {
                            confirmationID = dalRes.BookReservation(site.Site_Id, userInputName, arrivalDate, departureDate);
                            Console.WriteLine();
                            Console.WriteLine($"The Reservation has been made for {userInputName} and the Confirmation ID# is {confirmationID}");
                            Freeze();
                            break;
                        }
                        else
                        {
                            Console.WriteLine();
                            Console.WriteLine("You entered an invalid ID");
                            Freeze();
                        }
                    }

                    Console.Write("Enter any key to add another reservation or Enter (X) to EXIT ");
                    char userInput = Console.ReadKey(false).KeyChar;
                    if (userInput.ToString().ToLower() == "x")
                    {
                        Console.WriteLine();
                        Environment.Exit(0);
                    }
                }

                else
                {
                    Console.WriteLine("****THERE ARE CURRENTLY NO AVAILABLE CAMPSITES IN THAT CAMPGROUND IN THAT TIME PERIOD****");
                    Freeze();
                    break;
                }
            }
        }