Esempio n. 1
0
        public ActionResult DeleteConfirmed(int?id)
        {
            AnswerDTO answerDTO = AnswerService.GetAnswer(id);

            AnswerService.DeleteAnswer(id.Value);
            return(RedirectToAction("Details", "Questions", new { id = answerDTO.Question_ID }));
        }
Esempio n. 2
0
        public IActionResult DeleteConfirmed(Guid id)
        {
            var answer = _service.GetAnswerById(id);

            _service.DeleteAnswer(answer);

            return(RedirectToAction("Index", "Questions"));
        }
        public ActionResult DeleteAnswer(int answerId)
        {
            int TestId     = (int)TempData.Peek("TestId");
            int QuestionId = (int)TempData.Peek("QuestionId");

            answerService.DeleteAnswer(answerId);
            return(RedirectToAction("DisplayAnswers", new { questionId = QuestionId, testId = TestId }));
        }
Esempio n. 4
0
 private async Task DeleteOldAnswers(IEnumerable <Answer> oldAnswers, QuizQuestion question)
 {
     foreach (var oldAns in oldAnswers)
     {
         var matches = question.Answers.Where(a => a.Id == oldAns.Id).ToList();
         if (matches.Count == 0)
         {
             await _answerService.DeleteAnswer(oldAns);
         }
     }
 }
Esempio n. 5
0
        public ActionResult DeleteQuestion(int?questionId)
        {
            if (questionId == null)
            {
                return(View("Error"));
            }
            QuestionViewModel          qvm     = questionService.GetById(questionId.Value).ToMvcQuestion();
            IEnumerable <AnswerEntity> answers = answerService.GetAllAnswers(qvm.ToBllQuestion());

            foreach (AnswerEntity a in answers)
            {
                answerService.DeleteAnswer(a);
            }
            IEnumerable <UsersAnswersEntity> usersAnswers = usersAnswerService.GetByPredicate(entity => entity.QuestionId == qvm.Id);

            foreach (UsersAnswersEntity e in usersAnswers)
            {
                usersAnswerService.DeleteAnswer(e);
            }
            List <QuestionEntity> questions =
                questionService.GetAllTestQuestions(testService.GetById(qvm.TestId)).ToList();
            bool dec = false;

            for (int i = 0; i < questions.Count; i++)
            {
                if (dec && questions[i].QuestionNumberInTest != null)
                {
                    questions[i].QuestionNumberInTest--;
                }
                if (qvm.Id == questions[i].Id)
                {
                    questionService.DeleteQuestion(qvm.ToBllQuestion());
                    dec = true;
                }
            }
            TestEntity test = testService.GetById(qvm.TestId);

            test.QuestionCount--;
            testService.UpdateTest(test);
            return(RedirectToAction("EditTest", new { testId = qvm.TestId }));
        }
        public ActionResult DeleteAnswer(Answer answer)
        {
            Log.Debug($"Deleting {answer.Ans}");

            try
            {
                answerService.DeleteAnswer(answer);
                Log.Info($"{answer.Ans} was deleted succesfully");
            }
            catch (Exception e)
            {
                Log.Error(e.ToString());
            }
            return(RedirectToAction("Answers"));
        }
        public async Task <ActionResult> _DeleteAnswer(Guid answerId, Guid questionId)
        {
            OperationDetails result = await _answerService.DeleteAnswer(answerId);

            if (result.Succeeded)
            {
                TempData["PartialMessageSuccess"] = result.Message;
            }
            else
            {
                TempData["PartialMessageFailure"] = result.Message;
            }

            return(RedirectToAction("_AnswersForQuestion", "Panel", new { questionId = questionId }));
        }
 public IActionResult DeleteAnswer(string id)
 {
     try
     {
         _answerService.DeleteAnswer(id);
     }
     catch (NotFoundException ex)
     {
         return(NotFound(ex.Message));
     }
     catch (Exception)
     {
         return(StatusCode(500));
     }
     return(Ok(new { Message = "Answer was successfully deleted!" }));
 }
Esempio n. 9
0
        public void DeleteQuestion(int questionId)
        {
            var question = _context.Questions
                           .Include(q => q.Answers)
                           .FirstOrDefault(q => q.Id == questionId);

            if (question != null)
            {
                while (question.Answers.FirstOrDefault() != null)
                {
                    answerService.DeleteAnswer(question.Answers.FirstOrDefault().Id);
                }
                _context.Questions.Remove(question);
                _context.SaveChanges();
            }
        }
 public IHttpActionResult Delete(int id)
 {
     if (id == null)
     {
         return(BadRequest());
     }
     try
     {
         _answerService.DeleteAnswer(id);
     }
     catch (BILException myExc)
     {
         return(InternalServerError(myExc));
     }
     return(Ok());
 }
Esempio n. 11
0
        public async Task <IActionResult> DeleteAnswerById([FromRoute] int answerId)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            try
            {
                var response = await _answerService.DeleteAnswer(answerId);

                if (response.Error != null)
                {
                    return(StatusCode(response.Error.ErrorCode, response.Error.ErrorDescriprion));
                }
                return(Ok(response.Data));
            }
            catch (Exception ex)
            {
                return(StatusCode(500, new Error(ex.Message)));
            }
        }
Esempio n. 12
0
 public IActionResult DeleteAnswer(int answerId)
 {
     answerService.DeleteAnswer(answerId);
     return(NoContent());
 }
Esempio n. 13
0
 public void DeleteAnswer(string id)
 {
     _answerService.DeleteAnswer(new Guid(id));
 }
Esempio n. 14
0
 public void Delete(int id)
 {
     _ias.DeleteAnswer(id);
 }
Esempio n. 15
0
 public IActionResult DeleteAnswer(int answerId)
 {
     _answerService.DeleteAnswer(answerId);
     return(Ok());
 }
Esempio n. 16
0
 // Delete chosen from db.
 public ActionResult DeleteAnswer(Guid id, Guid subjectId, Guid idTest)
 {
     answerService.DeleteAnswer(id);
     Logger.Log.Info("User " + User.Identity.GetUserId() + "delete answer " + id + " from test " + idTest);
     return(RedirectToAction("ViewQuestion", "TestQuestion", new { subjectId = subjectId, id = idTest }));
 }
Esempio n. 17
0
 // GET: Answers/Delete/5
 public ActionResult Delete(int?id, int?questionId)
 {
     _answerService.DeleteAnswer(id.Value);
     return(RedirectToAction("Details", "Questions", new { id = questionId }));
 }
        public async Task <IActionResult> DeleteAnswer([FromRoute] int answerId)
        {
            var result = await _answerService.DeleteAnswer(answerId);

            return(Ok(result));
        }