コード例 #1
0
        public void ViewSpaces(Venue venueInfo)
        {
            bool searchSpaceMenu = false;
            bool done            = false;

            while (!done)
            {
                Console.WriteLine(venueInfo.VenueName);
                Console.WriteLine("\n");

                ViewSpacesHeader();

                List <Space> listOfSpaces = spaceIO.GetSpacesForVenue(venueInfo.VenueID);

                int counter = 1;

                foreach (Space individulaSpace in listOfSpaces)
                {
                    Console.WriteLine(" #" + counter.ToString().PadRight(3) + individulaSpace.SpaceName.PadRight(40) +
                                      individulaSpace.OpenTo.PadRight(6) + individulaSpace.OpenFrom.PadRight(8) +
                                      "$" + individulaSpace.DailyRate.ToString().PadRight(13) +
                                      individulaSpace.MaxOccupancy.ToString().PadRight(10));

                    counter++;
                }
                Console.WriteLine();
                Console.WriteLine("What would you like to do next?");
                Console.WriteLine("\t1) Reserve a Space");
                Console.WriteLine("\tR) Return to Previous Screen");
                string menuInput = Console.ReadLine();
                if (menuInput == "1")
                {
                    done            = true;
                    searchSpaceMenu = true;
                }
                else if (menuInput == "R")
                {
                    done = true;
                }
                else
                {
                    Console.WriteLine("Invalid Entry, please enter 1 or R");
                }
            }
            if (searchSpaceMenu)
            {
                SearchSpacesMenu(venueInfo);
            }
            else
            {
                VenueInfoMenu(venueInfo.VenueName);
            }
        }
コード例 #2
0
        public void GetSpacesForVenueTest()
        {
            //Arrange
            SpacesDAL testObj = new SpacesDAL(connectionString);
            int       newId   = 0;

            using (SqlConnection conn = new SqlConnection(connectionString))
            {
                conn.Open();

                string sqlInsertVenue        = "INSERT INTO venue (name, city_id, description) VALUES ('ZZZZ', 3, 'XXXX')";
                string sqlGetInsertedVenueID = "SELECT id FROM venue WHERE name = 'ZZZZ'";
                string sqlInsertSpaces       = "INSERT INTO space (venue_id, name, is_accessible, daily_rate, max_occupancy) VALUES (@id, 'YYYY', 1, 400.00, 100)"
                                               + "INSERT INTO space (venue_id, name, is_accessible, daily_rate, max_occupancy) VALUES (@id, 'VVVV', 1, 3500.00, 200); ";

                SqlCommand cmd   = new SqlCommand(sqlInsertVenue, conn);
                int        count = cmd.ExecuteNonQuery();

                cmd = new SqlCommand(sqlGetInsertedVenueID, conn);
                SqlDataReader reader = cmd.ExecuteReader();

                while (reader.Read())
                {
                    newId = Convert.ToInt32(reader["id"]);
                }
                reader.Close();

                cmd = new SqlCommand(sqlInsertSpaces, conn);
                cmd.Parameters.AddWithValue("@id", newId);
                cmd.ExecuteNonQuery();
            }

            //Act
            List <Space> result = testObj.GetSpacesForVenue(newId);

            //Assert
            Assert.AreEqual(2, result.Count);
        }