Example #1
0
        /// <summary>
        /// Tony Noel
        /// Created: 2015/02/05
        ///
        /// EditBooking- a method used to update a booking through the data access layer to be added to the database
        /// As the BookingID number will not change or be updated in the database the method uses the same booking ID number to search
        /// the database through the Retrieve Booking method. This will pull the originally record into an object "oldOne". Then the
        /// original record and the new booking object that was passed to the method can both be passed to upDateBooking to be updated.
        /// </summary>
        /// <param name="newOne">Takes an input of a booking object</param>
        /// <returns> Returns an int- the number of rows affected, if add is successful</returns>
        public int EditBooking(Booking newOne)
        {
            Booking oldOne  = RetrieveBooking(newOne.BookingID);
            var     numRows = BookingAccessor.UpdateBooking(oldOne, newOne);

            return(numRows);
        }
Example #2
0
        public void TestGetEventListingAccess()
        { //A test to retrieve a single listing by ID from the ItemListing table.
            ItemListingDetails details = BookingAccessor.GetItemListingDetails(itemID);
            int expected = 1234;

            Assert.AreEqual(expected, details.Price);
        }
Example #3
0
        /// <summary>
        /// Pat Banks
        /// Created: 2015/03/19
        ///
        /// Takes data from the presentation layer and determines the results of attempting to add a booking
        /// </summary>
        /// <param name="bookingToAdd">Booking information from presentation Layer form</param>
        /// <returns>Results of adding the booking</returns>
        public ResultsEdit AddBookingResult(Booking bookingToAdd)
        {
            if (bookingToAdd.Quantity == 0)
            {
                return(ResultsEdit.QuantityZero);
            }
            try
            {
                //calls method to add a booking and update itemListing Table with current number of guests
                int result = BookingAccessor.AddBooking(bookingToAdd);

                if (result == 2)
                {
                    //update cache
                    RefreshItemListingDetailsListCacheData();

                    return(ResultsEdit.Success);
                }
                return(ResultsEdit.DatabaseError);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #4
0
        public void TestAddBookingAccess()
        {
            //Added to database and checked to see if an int row is returned, then compared to expected result
            int result   = BookingAccessor.AddBooking(booking);
            int expected = 2;

            Assert.AreEqual(expected, result);
        }
Example #5
0
        public void TestGetBookingNumbersAccessor()
        {
            //Checks using the dummy itemListing, returns a BookingNumbers object(nums)
            //Asserts that a record is found, that nums is not null
            List <BookingNumbers> nums = BookingAccessor.GetBookingNumbers(100);

            Assert.IsNotNull(nums);
        }
Example #6
0
        public void TestGetBookingbyIDAccess()
        {   // Retrieves a booking from the database by ID, first captures the dummy booking from database
            //using a TestAccessor, then uses a real accessor method to be tested.
            BookingID = TestCleanupAccessor.GetBooking();
            Booking booking2 = BookingAccessor.GetBooking(BookingID);
            decimal expected = 1234;

            Assert.AreEqual(expected, booking2.TicketPrice);
        }
Example #7
0
        public void TestVerifyGuestPINBookingAccessor()
        {   //Pulls a guest from the database and collects the guest information
            List <HotelGuest> guest1 = HotelGuestAccessor.HotelGuestGet(100);
            //Checks using a pin in the database, stores guest info from database into a guest object
            //Asserts that a record is found, that guest is not null by passing the guest1 guest pin
            HotelGuest guest = BookingAccessor.VerifyHotelGuestPin(guest1[guest1.Count - 1].GuestPIN);

            Assert.IsNotNull(guest);
        }
Example #8
0
 /// <summary>
 /// Matt Lapka
 /// Created: 2015/04/14
 /// Retrieves numbers from a specific event listing
 /// Not cached since it will differ each time
 /// </summary>
 /// <param name="itemListID">The ID of event listing</param>
 /// <returns>Names of hotel guests, room numbers, and quantities of tickets for each booking related to that item listing</returns>
 public List <BookingNumbers> RetrieveBookingNumbers(int itemListID)
 {
     try
     {
         return(BookingAccessor.GetBookingNumbers(itemListID));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Example #9
0
 /// <summary>
 /// Pat Banks
 /// Created: 2015/03/30
 ///
 /// Passes data to the Accessor to verify that the pin is not being used.
 /// </summary>
 /// <param name="inPIN">The pin to crossreference against</param>
 /// <returns>A HotelGuest object whose pin matches the one passed</returns>
 public HotelGuest CheckValidPIN(string inPIN)
 {
     try
     {
         //retrieve guest
         return(BookingAccessor.VerifyHotelGuestPin(inPIN));
     }
     catch (Exception ax)
     {
         throw ax;
     }
 }
Example #10
0
 public Booking RetrieveBooking(int bookingId)
 {
     try
     {
         return(BookingAccessor.GetBooking(bookingId));
     }
     catch (Exception)
     {
         var ax = new ApplicationException("There was a problem accessing your data.");
         throw ax;
     }
 }
Example #11
0
        public void TestGetListItemsAccess()
        { //A test to retrieve a listing of ItemListingDetails, checks to ensure that a list of ItemListingDetails
            //is being returned and that the count is greater than 1 record.
            List <ItemListingDetails> details = BookingAccessor.GetItemListingDetailsList();
            bool worked = false;

            if (details.Count > 1)
            {
                worked = true;
            }
            Assert.IsTrue(worked);
        }
Example #12
0
        /// <summary>
        /// Pat Banks
        /// Created: 2015/03/30
        ///
        /// Refreshes the data cache
        /// </summary>
        private void RefreshItemListingDetailsListCacheData()
        {
            //data hasn't been retrieved yet. get data, set it to the cache and return the result.
            var activeEventListings = BookingAccessor.GetItemListingDetailsList();

            //calculating the quantity of available tickets for each listing
            foreach (ItemListingDetails lIO in activeEventListings)
            {
                lIO.QuantityOffered = AvailableQuantity(lIO.MaxNumGuests, lIO.CurrentNumGuests);
            }

            DataCache._currentItemListingDetailsList = activeEventListings;
            DataCache._ItemListingDetailsListTime    = DateTime.Now;
        }
Example #13
0
        public void TestUpdateBookingAccess()
        {   // Updates the dummy booking in the database, first captures the dummy bookingID from database
            //using a TestAccessor
            BookingID = TestCleanupAccessor.GetBooking();
            //Assigns one booking object to be the old record and one to be the new record
            Booking old  = BookingAccessor.GetBooking(BookingID);
            Booking newB = new Booking(guestID, empID, itemID, 3, dateBooked, ticket, extended, discount, total);
            //Updates the old with the new quantity
            int rows     = BookingAccessor.UpdateBooking(old, newB);
            int expected = 3;
            //Grabs the record to test and see if the update went through
            Booking toCheck = BookingAccessor.GetBooking(BookingID);

            Assert.AreEqual(expected, toCheck.Quantity);
        }
Example #14
0
        /// <summary>
        /// Pat Banks
        /// Created: 2015/03/11
        ///
        /// Retrieves Event Listing information for the one selected item listing
        /// Information is human readable with data from joined tables
        /// </summary>
        /// <param name="itemListID">ItemList ID matching an ItemListingDetails record</param>
        /// <returns>an ItemListingDetails containing the item listing information</returns>
        public ItemListingDetails RetrieveItemListingDetailsList(int itemListID)
        {
            var    now = DateTime.Now;
            double cacheExpirationTime = 5;

            try
            {
                if (DataCache._currentItemListingDetailsList == null)
                {
                    return(BookingAccessor.GetItemListingDetails(itemListID));
                }
                //check time. If less than 5 min, return event from cache
                if (now > DataCache._ItemListingDetailsListTime.AddMinutes(cacheExpirationTime))
                {
                    //get event from DB
                    var requestedEvent = BookingAccessor.GetItemListingDetails(itemListID);
                    return(requestedEvent);
                }
                else
                {
                    //get event from cached list
                    var list = DataCache._currentItemListingDetailsList;
                    ItemListingDetails requestedEvent = new ItemListingDetails();
                    requestedEvent = list.Where(e => e.ItemListID == itemListID).FirstOrDefault();

                    if (requestedEvent != null)
                    {
                        return(requestedEvent);
                    }
                    throw new ApplicationException("Event not found.");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #15
0
 public void SetupDriver()
 {
     _webDriver = new ChromeDriver();
     _booking   = new BookingAccessor(_webDriver);
 }
Example #16
0
 public void AddBooking()
 {
     int result = BookingAccessor.AddBooking(booking);
 }