protected void ButtonMoveQuestion_Click1(object sender, EventArgs e) { try { CheckForDangerousInput(Textbox_QuestionKey_Move_Question_From, Textbox_IssueKey_Move_To); var questionKeyFrom = Textbox_QuestionKey_Move_Question_From.Text.Trim(); var issueKeyTo = Textbox_IssueKey_Move_To.Text.Trim(); if (!Questions.QuestionKeyExists(questionKeyFrom)) { throw new ApplicationException($"The QuestionKey({questionKeyFrom}) does not exist"); } if (!Issues.IssueKeyExists(issueKeyTo)) { throw new ApplicationException($"The IssueKey({issueKeyTo}) does not exist."); } // Create a new QuestionKey for the new Issue var newQuestionKey = issueKeyTo; newQuestionKey += MakeUnique6Digits(); if (Questions.QuestionKeyExists(newQuestionKey)) { throw new ApplicationException($"The new QuestionKey ({newQuestionKey}) already exist"); } //Update Questions with new QuestionKey and IssueKey Questions.UpdateIssueKeyByQuestionKey(issueKeyTo, questionKeyFrom); Questions.UpdateQuestionKeyByQuestionKey(newQuestionKey, questionKeyFrom); //Update all the Answers with the new QuestionKey Answers.UpdateIssueKeyByQuestionKey(issueKeyTo, questionKeyFrom); Answers.UpdateQuestionKeyByQuestionKey(newQuestionKey, questionKeyFrom); Msg.Text = Ok($"Question: ({Questions.GetQuestion(newQuestionKey)}) has been moved to Issue" + $" ({Issues.GetIssue(issueKeyTo, Empty)})"); } catch (Exception ex) { Msg.Text = Fail(ex.Message); LogAdminError(ex); } }