Exemple #1
0
        public void commit()
        {
            // To be verified with respective mappers
            //if (userNewList.Count() != 0)
            //userMapper.AddUser(userNewList);
            //prof doesn't want add users in our case
            //if (userChangedList.Count() != 0)
            //    userMapper.updateUser(userChangedList);
            //if (userDeletedList.Count() != 0)
            //    userMapper.deleteUser(userDeletedList);

            if (reservationNewList.Count() != 0)
            {
                reservationMapper.addReservation(reservationNewList);
            }
            if (reservationChangedList.Count() != 0)
            {
                reservationMapper.updateReservation(reservationChangedList);
            }
            if (reservationDeletedList.Count() != 0)
            {
                reservationMapper.deleteReservation(reservationDeletedList);
            }

            if (roomNewList.Count() != 0)
            {
                roomMapper.addRoom(roomNewList);
            }
            if (roomChangedList.Count() != 0)
            {
                roomMapper.updateRoom(roomChangedList);
            }
            if (roomDeletedList.Count() != 0)
            {
                roomMapper.deleteRoom(roomDeletedList);
            }

            if (timeSlotNewList.Count() != 0)
            {
                timeSlotMapper.addTimeSlot(timeSlotNewList);
            }
            if (timeSlotChangedList.Count() != 0)
            {
                timeSlotMapper.updateTimeSlot(timeSlotChangedList);
            }
            if (timeSlotDeletedList.Count() != 0)
            {
                timeSlotMapper.deleteTimeSlot(timeSlotDeletedList);
            }

            //Empty the lists after the Commit.
            userDeletedList.Clear();
            userChangedList.Clear();
            userNewList.Clear();
            reservationDeletedList.Clear();
            reservationChangedList.Clear();
            reservationNewList.Clear();
            roomDeletedList.Clear();
            roomChangedList.Clear();
            roomNewList.Clear();
            timeSlotNewList.Clear();
            timeSlotChangedList.Clear();
            timeSlotDeletedList.Clear();
        }