public bool SelectedDelete(string ids) { try { if (!string.IsNullOrEmpty(ids)) { if (ids.StartsWith(",")) { ids = ids.Remove(0, 1); } if (ids.EndsWith(",")) { ids = ids.Remove(ids.Length - 1, 1); } var silinecekler = ids.Split(','); for (int i = 0; i < silinecekler.Length; i++) { _answerService.Delete(Convert.ToInt32(silinecekler[i])); } return(true); } else { return(false); } } catch (Exception e) { return(false); } }
// GET: BackOffice/Answer/Delete/5 public IActionResult Delete(int id, int questionId) { var question = _answerService.Get(m => m.Id == id); if (question == null) { return(NotFound()); } _answerService.Delete(question); return(View("Create", new AnswerViewModel { QuestionId = questionId, Answers = _answerService.List(x => x.QuestionId == questionId).ToList() })); }
public IActionResult Delete(int id) { _answerService.Delete(id); return(Ok(new { message = "Successfully deleted user answer." })); }
public ActionResult DeleteConfirmed(int id) { Answer answer = answerService.Get(id); answerService.Delete(answer); return(RedirectToAction("Index")); }
public IActionResult Delete(int id) { var answer = _service.Get(a => a.Id == id); _service.Delete(answer); return(Ok()); }
public IActionResult DeleteConfirm(int id) { AnswerVM answer = _answerService.GetById(id); _answerService.Delete(answer.AnswerId); return(RedirectToAction("Index")); }
public async Task <IActionResult> Delete(int id) { if (ModelState.IsValid) { return(Ok(await _service.Delete(id))); } return(BadRequest()); }
public ActionResult Delete(int id) { if (_answerService.Delete(id)) { return(View("Index")); } return(View("Index")); }
public async Task <IActionResult> Delete([FromRoute] int id) { bool result = await answerServices.Delete(id); if (result == true) { return(Ok(Properties.Resources.ResourceManager.GetString("SuccDeleteMessage"))); } return(NotFound()); }
public ActionResult Delete(int id) { try { _answerService.Delete(_answerService.GetById(id)); SuccessNotification("Kayıt Silindi"); return(RedirectToAction("AnswerIndex")); } catch { return(View()); } }
public IActionResult Delete(int id) { Answer answerToDelete = _answerService.Get(id); if (answerToDelete != null) { _answerService.Delete(answerToDelete); return(RedirectToAction(nameof(Index))); } return(NotFound()); }
public ActionResult Delete(int id) { var model = _answerService.GetByQuestionId(id).ToList(); foreach (var item in model) { _answerService.Delete(item.answerId); _answerService.Save(); } _questionService.Delete(id); _questionService.Save(); return(Json(true, JsonRequestBehavior.AllowGet)); }
public ActionResult DeleteQuestionAnswer(int?answerId) { if (answerId == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var answer = answerService.GetOneByPredicate(a => a.Id == answerId); if (answer == null) { return(HttpNotFound()); } answerService.Delete(answer); return(RedirectToAction("DetailsQuestionAnswers", "Answer", new { questionId = answer.QuestionId })); }
public IHttpActionResult DeleteAnswer([FromBody] AnswerModel answer) { AnswerDTO answerDTO; try { answerDTO = _answerService.Delete(Mapper.Map <AnswerModel, AnswerDTO>(answer)); } catch (Exception ex) { return(InternalServerError()); } return(Ok(Mapper.Map <AnswerDTO, AnswerModel>(answerDTO))); }
public ActionResult Delete(int id) { try { AnswerService.Delete(id); } catch (NotFoundException) { return(HttpNotFound()); } catch (HasRelationsException) { return(Content("Удаление невозможно.")); } return(RedirectToAction("Index")); }
public ActionResult DeleteAnswer(int answerId) { AnswerDTO deleteAnswer = answerService.GetById(answerId); string type = questService.GetById(questionService.GetById(deleteAnswer.QuestionId).QuestId).Type; int id = deleteAnswer.QuestionId; Debug.WriteLine("DELETE " + id + " " + type); if (deleteAnswer != null) { answerService.Delete(answerId); TempData["message"] = string.Format("Удаление \"{0}\" выполнено успешно", deleteAnswer.Text_of_answer); } if (userService.GetUserByEmail(User.Identity.Name).RoleId == 2) { return(RedirectToAction("TeacherPanel", "Teacher", new { result = "answers", questType = type, id = id })); } return(RedirectToAction("AdminPanel", "Admin", new { result = "answers", questType = type, id = id })); }
public IActionResult DeleteAnswer(int id) { try { var result = _AnswerService.Delete(id); if (result.IsSucceeded) { return(Ok(result.Result)); } return(BadRequest(result.HttpGetResponse())); //return result.HttpGetResponse(); } catch (Exception e) { return(BadRequest(e.Message)); } }
public JsonResult Delete(int id = 0) { try { var entity = _AnswerService.GetById(id); if (entity == null) { return(Json(new { Status = Successed.Empty }, JsonRequestBehavior.AllowGet)); } _AnswerService.Delete(entity); return(Json(new { Status = Successed.Ok }, JsonRequestBehavior.AllowGet)); } catch (Exception) { return(Json(new { Status = Successed.Error }, JsonRequestBehavior.AllowGet)); } }
private void btn_delete_Click(object sender, EventArgs e) { if (lv_questionList.SelectedItems.Count > 0) { var question = (QuestionModel)lv_questionList.SelectedItems[0].Tag; var answers = answerService.GetAll().Where(x => x.QuestionID == question.QuestionID).ToList(); foreach (var answer in answers) { answerService.Delete(answer.AnswerID); } questionService.Delete(question.QuestionID); MessageBox.Show("The question was deleted", "Success"); DisplayQuestions(); } else { MessageBox.Show("Please select a question", "Error"); } }
public ActionResult DeleteAnswer(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var model = _answerService.Get(id.Value); if (model == null) { return(new HttpStatusCodeResult(HttpStatusCode.NotFound)); } _answerService.Delete(id.Value); var question = _questionService.Get(model.QuestionId); var vm = question.ToEditQuestionViewModel(_answerService, _quizService); return(PartialView("_EditQuestionPartial", vm)); }
public ActionResult DeleteAnswer(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var model = _answerService.Get(id.Value); if (model == null) { return(new HttpStatusCodeResult(HttpStatusCode.NotFound)); } _answerService.Delete(id.Value); var question = _questionService.Get(model.QuestionId); var vm = _modelConverter.ToEditQuestionViewModel(question); _userActivityService.Add(User.Identity.Name, ActivityItem.Answer, ActivityAction.Delete, id.Value); return(PartialView("_EditQuestionPartial", vm)); }
public ActionResult SaveAsyncQuestion(string examID, string questionID, AsyncEditedDataViewModel questionData, List <AsyncEditedDataViewModel> answersData) { if (int.TryParse(questionID, out int questionIntID)) { var editedQuestion = _questionService.GetByID(questionIntID); if (questionData != null && questionData.oldValue != null && questionData.newValue != null) { editedQuestion.QuestionText = questionData.newValue; } if (questionData != null && questionData.secondNewValue != null && questionData.secondNewValue == "true") { _questionService.Delete(editedQuestion); return(Json( new { success = true, responseText = "Question has been successfuly deleted!", deleted = true }, JsonRequestBehavior.AllowGet)); } var editedAnswers = new List <Answer>(); var addedAnswers = new List <Answer>(); if (answersData != null && answersData.Any()) { foreach (var answerData in answersData) { var editedAnswer = editedQuestion.Answers.Where(x => x.TextAnswer == answerData.oldValue).FirstOrDefault(); if (editedAnswer != null) { editedAnswer.TextAnswer = answerData.newValue; editedAnswer.IfCorrect = answerData.secondNewValue == "true" ? true : false; editedAnswers.Add(editedAnswer); } else { var addedAnswer = new Answer() { IfCorrect = answerData.secondNewValue == "true" ? true : false, TextAnswer = answerData.newValue }; _questionService.AddAnswerToQuestion(questionIntID, addedAnswer); addedAnswers.Add(addedAnswer); } } var allAnswers = _questionService.GetByID(questionIntID).Answers.ToList(); var deletedAnswers = allAnswers.Except(editedAnswers).ToList(); deletedAnswers = deletedAnswers.Except(addedAnswers).ToList(); foreach (var deletedAnswerr in deletedAnswers) { _answerService.Delete(deletedAnswerr.Id); } _questionService.Update(editedQuestion); } var returnedAnswers = editedAnswers.ToList(); if (addedAnswers.Any()) { returnedAnswers = returnedAnswers.Concat(addedAnswers.ToList()).ToList(); } return(Json( new { success = true, responseText = "Questions have been successfuly updated!", data = returnedAnswers.Select(x => new { TextAnswer = x.TextAnswer, IfCorrect = x.IfCorrect }).ToList(), newQuestionID = editedQuestion.Id }, JsonRequestBehavior.AllowGet)); } else { if (int.TryParse(examID, out int examIntID)) { var editedQuestion = new Question(); if (questionData != null && questionData.newValue != null) { editedQuestion.QuestionText = questionData.newValue; _examCoreService.AddQuestionToExam(examIntID, editedQuestion); } if (answersData != null && answersData.Any()) { foreach (var answerData in answersData) { var addedAnswer = new Answer() { IfCorrect = answerData.secondNewValue == "true" ? true : false, TextAnswer = answerData.newValue }; _questionService.AddAnswerToQuestion(editedQuestion.Id, addedAnswer); } } return(Json( new { success = true, responseText = "Questions have been successfuly updated!", data = _questionService.GetByID(editedQuestion.Id).Answers.Select(x => new { TextAnswer = x.TextAnswer, IfCorrect = x.IfCorrect }).ToList(), newQuestionID = editedQuestion.Id }, JsonRequestBehavior.AllowGet)); } } return(Json(new { success = false, responseText = "Error during updating questions." }, JsonRequestBehavior.AllowGet)); }
public async Task <Result <AnswerResponse> > Delete(Guid id) => await _service.Delete(new RemoveAnswerCommand() { Id = id });
public ActionResult Delete(Guid id) { _answerService.Delete(id); return(RedirectToAction("Index")); }
public IActionResult Delete(int id) { return(Ok(_answer.Delete(id))); }
public async Task <ActionResult> DeleteAnswer(int id) { await _answerService.Delete(id).ConfigureAwait(false); return(NoContent()); }
public IActionResult Delete(int id) { _service.Delete(id); return(Ok()); }
public JsonResult Delete(string _id) { return(Json(_AnswerService.Delete(_id))); }