コード例 #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);
        }
コード例 #2
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);
        }