public async Task <JsonResult> RemoveSurvey(string id) { var survey = surveyRepository.GetItems().Include(x => x.SurveyQuestion).ThenInclude(y => y.Options).ThenInclude(z => z.OptionsForAnswers).Include(x => x.SurveyQuestion).ThenInclude(a => a.UserAnswers).FirstOrDefault(x => x.Id == id); if (survey == null) { return(Json(null)); } foreach (var question in survey.SurveyQuestion.ToList()) { foreach (var option in question.Options.ToList()) { foreach (var optionsforanswer in option.OptionsForAnswers.ToList()) { await optionsForAnswerRepository.Delete(optionsforanswer); } await optionRepository.Delete(option); } foreach (var useranswers in question.UserAnswers.ToList()) { await userAnswerRepository.Delete(useranswers); } await surveyQuestionRepository.Delete(question); } await surveyRepository.Delete(survey); return(new JsonResult(id)); }
public bool Delete(Option item) { if (item == null) { return(false); } var findoptionid = _repository.Get(item.Id); if (findoptionid == null) { return(false); } bool optionsIsAssigned = _repository.optionIsAssigned(item.Id); if (optionsIsAssigned) { return(false); } bool result = _repository.Delete(item); return(result); }
//[Authorize] public async Task <IActionResult> DeleteOption(int id) { var option = await _optionRepository.GetOptionById(id); _optionRepository.Delete <Option>(option); if (await _optionRepository.SaveAll()) { return(Ok()); } return(BadRequest("Nie udało się usunąć opcji")); }
public Option Delete(int _id, string _userName) { try { LogAction entity = new LogAction(); entity.action = "Thêm option: <a href=\"" + _id + "\" target=\"_blank\">" + _id + "</a>"; entity.browser = ""; entity.ipAddress = ""; entity.userAction = _userName; entity.createTime = DateTime.Now; _RepositoryLogAction.Add(entity); } catch { } return(_Repository.Delete(_id)); }
public async Task <ActionResult> DeleteOption(Guid questionId, Guid optionId) { if (!await _questionRepository.isExists(questionId)) { return(NotFound()); } var optionFromRepo = await _optionRepository.GetOptionAsync(questionId, optionId); if (optionFromRepo == null) { return(NotFound()); } _optionRepository.Delete(optionFromRepo); if (!await _optionRepository.SaveChangesAsync()) { throw new Exception($"Deleting a option {optionId} for question {questionId} failed to delete."); } return(NoContent()); }
public void Delete(int id) { _optionRepository.Delete(id); }
public bool Delete(Option element) { return(_optionRepo.Delete(element)); }