public function updateBandAdvertisement($bandID, $advertisementID, $memberID, $changeKey, $advertisementTypeID, $dbConnection)
 {
     $processed = false;
     try {
         if (stripos($changeKey, AdvertisementEditConstants::BAND_INPUT_CHANGE_KEY) !== false) {
             BandAdvertisementController::deleteBandAdvertisement($advertisementID);
             if ($advertisementTypeID == '2') {
                 $bandID = $_POST[AdvertisementEditConstants::BAND_INPUT_ID];
                 if ($bandID != 'defaultValue') {
                     if (BandMemberController::isBandMemberAdmin($bandID, $memberID, $dbConnection)) {
                         BandAdvertisementController::createBandAdvertisement($bandID, $advertisementID, $dbConnection);
                     }
                 }
             }
             $processed = true;
         }
     } catch (Exception $ex) {
         $processed = false;
         echo 'Caught exception: ' . $ex->getMessage();
     }
     return $processed;
 }
 $memberID = LoginController::getLoggedInMemberID($dbConnection);
 if ($memberID != null) {
     if (isset($_POST[AdvertisementCreateConstants::SUBMISSION_KEY_INPUT])) {
         $submissionKey = $_POST[AdvertisementCreateConstants::SUBMISSION_KEY_INPUT];
         echo "Submission Key " . $submissionKey;
         if (MemberSubmissionController::checkSubmissionKey($memberID, $submissionKey, $dbConnection)) {
             $inputMemberID = $_POST[AdvertisementCreateConstants::MEMBER_ID_INPUT];
             $encryptedID = $_POST[AdvertisementCreateConstants::ENCRYPTED_ID_INPUT];
             if (AdvertisementController::processAdvertisementCreateSecurityCheck($memberID, $inputMemberID, $encryptedID)) {
                 $advertisementID = AdvertisementController::createAdvertisement($memberID, $_POST[AdvertisementCreateConstants::FOR_INPUT_ID], $_POST[AdvertisementCreateConstants::SUMMARY_INPUT_ID], $_POST[AdvertisementCreateConstants::DESCRIPTION_INPUT_ID], $_POST[AdvertisementCreateConstants::INSPIRATIONS_INPUT_ID], $_POST[AdvertisementCreateConstants::BAND_INPUT_ID], $_POST[LocationConstants::LOCATION_COUNTRY_INPUT_ID], $_POST[LocationConstants::LOCATION_STATE_INPUT_ID], $_POST[LocationConstants::LOCATION_CITY_INPUT_ID], $_POST[LocationConstants::LOCATION_REGION_INPUT_ID], $dbConnection);
                 if ($advertisementID > 0) {
                     //If advertisement is for a position in a band.
                     if ($_POST[AdvertisementCreateConstants::FOR_INPUT_ID] == 2) {
                         $bandID = $_POST[AdvertisementCreateConstants::BAND_INPUT_ID];
                         if (BandMemberController::isBandMemberAdmin($bandID, $memberID, $dbConnection)) {
                             BandAdvertisementController::createBandAdvertisement($bandID, $advertisementID, $dbConnection);
                         }
                     }
                     if (AdvertisementGenreController::createAdvertisementGenres($advertisementID, $memberID, $_POST[AdvertisementCreateConstants::GENRE_INPUT_ID], $dbConnection)) {
                         $positionCount = $_POST[AdvertisementCreateConstants::POSITION_COUNT_ID];
                         echo "Position Count : " . $positionCount;
                         $positionList = null;
                         for ($i = 1; $i <= $positionCount; $i++) {
                             $position = new AdvertisementPosition();
                             $position->setVariable(AdvertisementPosition::ADVERTISEMENT_ID, $advertisementID);
                             $position->setVariable(AdvertisementPosition::POSITION_NUMBER, $i);
                             $position->setVariable(AdvertisementPosition::INSTRUMENT_ID, $_POST[AdvertisementPositionConstants::POSITION_TYPE_INPUT_ID . $i]);
                             $position->setVariable(AdvertisementPosition::DURATION_ID, $_POST[AdvertisementPositionConstants::POSITION_DURATION_INPUT_ID . $i]);
                             $position->setVariable(AdvertisementPosition::EXPERIENCE_ID, $_POST[AdvertisementPositionConstants::POSITION_EXP_INPUT_ID . $i]);
                             $position->setVariable(AdvertisementPosition::GENDER_ID, $_POST[AdvertisementPositionConstants::POSITION_GENDER_INPUT_ID . $i]);
                             $position->setVariable(AdvertisementPosition::AGE_RANGE_ID, $_POST[AdvertisementPositionConstants::POSITION_AGE_INPUT_ID . $i]);
$advertisementID = null;
$dbConnection = null;
$memberID = null;
$processed = false;
try {
    $dbConnection = DatabaseUtilities::getDatabaseConnection();
    //Get the current user's ID and details.
    $memberID = LoginController::getLoggedInMemberID($dbConnection);
    if ($memberID != null) {
        $submissionKey = $_POST[AdvertisementEditConstants::SUBMISSION_KEY_INPUT];
        if (MemberSubmissionController::checkSubmissionKey($memberID, $submissionKey, $dbConnection)) {
            if (AdvertisementController::processAdvertisementUpdateSecurityCheck($memberID, $_POST[AdvertisementEditConstants::MEMBER_ID_INPUT], $_POST[AdvertisementEditConstants::ENCRYPTED_ID_INPUT], $_POST[AdvertisementEditConstants::ADVERTISEMENT_ID_INPUT], $_POST[AdvertisementEditConstants::KEY])) {
                $advertisementID = $_POST[AdvertisementEditConstants::ADVERTISEMENT_ID_INPUT];
                $changeKey = $_POST[AdvertisementEditConstants::CHANGED_INPUT_ID];
                AdvertisementController::updateAdvertisement($memberID, $changeKey, $advertisementID, $_POST[AdvertisementEditConstants::FOR_INPUT_ID], $_POST[AdvertisementEditConstants::BAND_INPUT_ID], $_POST[AdvertisementEditConstants::SUMMARY_INPUT_ID], $_POST[AdvertisementEditConstants::INSPIRATIONS_INPUT_ID], $_POST[AdvertisementEditConstants::DESCRIPTION_INPUT_ID], $_POST[LocationConstants::LOCATION_COUNTRY_INPUT_ID], $_POST[LocationConstants::LOCATION_STATE_INPUT_ID], $_POST[LocationConstants::LOCATION_CITY_INPUT_ID], $_POST[LocationConstants::LOCATION_REGION_INPUT_ID], $dbConnection);
                BandAdvertisementController::updateBandAdvertisement($_POST[AdvertisementEditConstants::BAND_INPUT_ID], $advertisementID, $memberID, $changeKey, $_POST[AdvertisementEditConstants::FOR_INPUT_ID], $dbConnection);
                AdvertisementGenreController::updateAdvertisementGenres($advertisementID, $memberID, $changeKey, $_POST[AdvertisementEditConstants::GENRE_INPUT_ID], $dbConnection);
                //Update advertisement positions.
                if ($_POST[AdvertisementEditConstants::POSITION_COUNT_ID] > 0) {
                    $i = 1;
                    $positionCount = $_POST[AdvertisementEditConstants::POSITION_COUNT_ID];
                    for ($i = 1; $i <= $_POST[AdvertisementEditConstants::POSITION_COUNT_ID]; $i++) {
                        $advertisementPositionID = $_POST[AdvertisementPositionConstants::ADVERTISEMENT_POSITION_ID . $i];
                        if ($advertisementPositionID == null) {
                            AdvertisementPositiionController::createAdvertisementPosition($advertisementID, $memberID, $i, $_POST[AdvertisementPositionConstants::POSITION_TYPE_INPUT_ID . $i], $_POST[AdvertisementPositionConstants::POSITION_DURATION_INPUT_ID . $i], $_POST[AdvertisementPositionConstants::POSITION_OTHER_INPUT_ID . $i], $_POST[AdvertisementPositionConstants::POSITION_EXP_INPUT_ID . $i], $_POST[AdvertisementPositionConstants::POSITION_AGE_INPUT_ID . $i], $_POST[AdvertisementPositionConstants::POSITION_GENDER_INPUT_ID . $i], $dbConnection);
                        } else {
                            AdvertisementPositiionController::updateAdvertisementPosition($advertisementPositionID, $_POST[AdvertisementPositionConstants::CHANGE_KEY_INPUT . $i], $advertisementID, $memberID, $i, $_POST[AdvertisementPositionConstants::POSITION_TYPE_INPUT_ID . $i], $_POST[AdvertisementPositionConstants::POSITION_DURATION_INPUT_ID . $i], $_POST[AdvertisementPositionConstants::POSITION_OTHER_INPUT_ID . $i], $_POST[AdvertisementPositionConstants::POSITION_EXP_INPUT_ID . $i], $_POST[AdvertisementPositionConstants::POSITION_AGE_INPUT_ID . $i], $_POST[AdvertisementPositionConstants::POSITION_GENDER_INPUT_ID . $i], $dbConnection);
                        }
                    }
                }
                $processed = true;