public IActionResult CreateQuestion([FromBody] Question question) { if (ModelState.IsValid) { var created = _questionRepo.AddEntity(question); return(Created($"https://localhost:5003/api/quizresults/{created.Id}", created)); } else { return(BadRequest("ModelState is not valid.")); } }
public IActionResult AddQuestion(QuestionData value) { var NewQuestion = new Question { Id = Guid.NewGuid(), Title = value.Title, DateAdded = value.DateAdded, Description = value.Description, CategoryId = value.CategoryId }; _questionRepository.AddEntity(NewQuestion); if (value.Images != null) { _imageRepository.AddImageToQuestion(value.Images, NewQuestion.Id); } return(Ok(new { QuestionId = NewQuestion.Id })); }
public Question AddEntity(Question entity) { return(questionRepository.AddEntity(entity)); }