Пример #1
0
 public JsonResult DeleteQuestion(Question question)
 {
     try
     {
         _questionRepository.DeleteQuestion(question);
         return(Json(new { msg = "Question deleted" }));
     }
     catch (Exception ex)
     {
         return(Json(new { msg = ex.Message }));
     }
 }
Пример #2
0
        private async void DeleteQuestion(int QuestionId)
        {
            var confirm = await SweetAlertMessage.ConfirmDialogAsync(Text : "Delete selected question");

            if (confirm == "Yes")
            {
                var deleted = await QuestionRepository.DeleteQuestion(QuestionId);

                if (deleted)
                {
                    var deleteItem = Survey.Questions.FirstOrDefault(p => p.QuestionId == QuestionId);
                    Survey.Questions.Remove(deleteItem);
                    await SweetAlertMessage.SuccessMessage();

                    StateHasChanged();
                }
                else
                {
                    await SweetAlertMessage.ErrorMessage();
                }
            }
        }
Пример #3
0
        static void Main(string[] args)
        {
            int                idQuest = 0, deleteid;
            string             questiontext, requiretext, menu;
            bool               requirement, exit = false;
            QuestionType       type;
            List <Questions>   questionList       = new List <Questions>();
            StreamWriter       sw                 = new StreamWriter("C:\\Users\\Academia\\Documents\\david_rodriguezv\\Practicas\\Survey\\Test.txt");
            QuestionRepository questionRepository = new QuestionRepository(questionList);

            do
            {
                Console.Clear();
                Console.WriteLine("Menu \n 1. Add question \n 2. Delete question \n 3. Take quizz \n 4. Exit");
                menu = Console.ReadLine();
                switch (menu)
                {
                case "1":
                    Console.WriteLine("Type the question:");
                    questiontext = Console.ReadLine();
                    sw.Write(questiontext);
                    Console.WriteLine("Is your question required?");
                    requiretext = Console.ReadLine();
                    sw.WriteLine(requiretext);
                    if (requiretext == "yes")
                    {
                        requirement = true;
                    }
                    else
                    {
                        requirement = false;
                    }
                    Console.WriteLine("What type of question it it?");
                    type = 0;
                    questionRepository.CreateQuestion(new Questions(idQuest, questiontext, requirement, type));
                    idQuest++;
                    break;

                case "2":
                    Console.WriteLine("Which id do you want to delete?");
                    deleteid = Convert.ToInt32(Console.ReadLine());
                    questionRepository.DeleteQuestion(deleteid);
                    break;

                case "3":
                    foreach (Questions question in questionList)
                    {
                        Console.WriteLine(question.Id + " " + question.Text + " " + question.Isrequired + " " + question.QuestionType);
                    }
                    Console.ReadKey();
                    break;

                case "4":
                    exit = true;
                    break;

                default:
                    Console.WriteLine("Select a valid option");
                    Console.ReadKey();
                    break;
                }
            } while (exit == false);

            sw.Close();
        }
Пример #4
0
 public ActionResult DeleteQuestion()
 {
     QuestionRepo.DeleteQuestion(Int32.Parse(Request.QueryString["questionID"]));
     QuestionRepo.Save();
     return(RedirectToAction("Index"));
 }
 public void Delete(int Id)
 {
     questionRepository.DeleteQuestion(Id);
 }
 public void DeleteQuestion(int questionID)
 {
     questionRepository.DeleteQuestion(questionID);
 }
Пример #7
0
 public Question DeleteQuestion(ApplicationDbContext _db, int Id)
 {
     return(_QuestionRepo.DeleteQuestion(_db, Id));
 }
Пример #8
0
 public IActionResult DeleteQuestion(int id, [FromQuery(Name = "quiz")] int quizId)
 {
     questionRepository.DeleteQuestion(quizId, id);
     return(Ok());
 }