private void DeleteCommandHandler()
        {
            if (MessageBox.ShowDialog(string.Format("Do you confirm delete {0} records.", SelectedItems.Count()), "Delete", System.Windows.Forms.MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
            {
                foreach (var item in SelectedItems.ToList())
                {
                    QuestionList.Remove(item);
                }
            }

            SaveCommand.Execute(null);
            RaiseCanExecuteChanged();
        }
Exemplo n.º 2
0
        async void RemoveQuestion(AmericanQuestion a)
        {
            if (QuestionList.Contains(a))
            {
                try
                {
                    TriviaWebAPIProxy proxy = TriviaWebAPIProxy.CreateProxy();
                    await proxy.DeleteQuestion(a);

                    QuestionList.Remove(a);
                }
                catch (Exception e) { }
            }
            Counter++;
            Able = true;
        }
Exemplo n.º 3
0
        public async void EditQuestion()
        {
            int indexOfNewQuestion = QuestionList.IndexOf(SelectedQuestion);

            QuestionList.Remove(SelectedQuestion);
            QnA_Model newQuestionEdit = new QnA_Model {
                Question = Question, Difficulty = Difficulty, Answer = Answer
            };

            QuestionList.Add(newQuestionEdit);
            int indexOfDeletedQuestion = QuestionList.IndexOf(newQuestionEdit);

            if (indexOfNewQuestion >= 0)
            {
                QuestionList.Move(indexOfDeletedQuestion, indexOfNewQuestion);
            }
            else
            {
                await App.Current.MainPage.DisplayAlert("No Flashcard Selected", "You must select a flashcard to edit!", "Gotcha!");
            }
        }
Exemplo n.º 4
0
        private void BtnDelete_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                //Check if the cboBox is not selecting anything
                if (cboQorAs.SelectedItem == null)
                {
                    throw new Exception("You must select a(n) " + qaMode.ToString() + " to delete");
                }
                else
                {
                    if (qaMode == QAMode.Answer)
                    {
                        //Delete the Answer
                        Answer answer = new Answer();
                        answer = answers.ElementAt(cboQorAs.SelectedIndex);

                        int result = answer.Delete();

                        if (result > 0)
                        {
                            lblStatus.Content = "Removed Answer: " + answer.Text;
                        }
                        else
                        {
                            throw new Exception("Answer not deleted");
                        }

                        //Remove from the answer list
                        answers.Remove(answer);

                        //Rebind the combobox
                        rebindComboBox(qaMode);
                    }
                    else
                    {
                        //Delete the Question
                        Question question = new Question();
                        question = questions.ElementAt(cboQorAs.SelectedIndex);

                        int result = question.DeleteQuestion();

                        if (result > 0)
                        {
                            lblStatus.Content = "Removed Question: " + question.Text;
                        }
                        else
                        {
                            throw new Exception("Question not deleted");
                        }

                        //Remove from the answer list
                        questions.Remove(question);

                        //Rebind the combobox
                        rebindComboBox(qaMode);
                    }
                }
            }
            catch (Exception ex)
            {
                lblStatus.Content = ex.Message;
            }
        }
 public void DeleteVragenlijst()
 {
     DataServer.RemoveVragenlijst(SelectedVragenlijst.VragenlijstModel);
     QuestionList.Remove(SelectedVragenlijst);
 }