public Question DeleteQuestion(string id)
        {
            var question = GetQuestionById(id);
            var deleted  = _repo.DeleteQuestion(id);

            if (!deleted)
            {
                throw new Exception($"Unable to remove Question ID: {id}");
            }
            return(question);
        }
        public Question DeleteQuestion(string id)
        {
            var question = GetQuestionById(id);

            if (question.AnswerId != null)
            {
                throw new Exception("Answered Questions cannot be deleted");
            }
            var deleted = _repo.DeleteQuestion(id);

            if (!deleted)
            {
                throw new Exception($"Could not delete question with ID {id}");
            }
            return(question);
        }
Example #3
0
 public String DeleteQuestion(int Id)
 {
     return(_repo.DeleteQuestion(Id));
 }