Esempio n. 1
0
        public async Task <QuestionDto> PatchQuestion([FromRoute] string id, [FromBody] JsonPatchDocument <QuestionDto> patch)
        {
            // Todo(AD): ModelState?
            var question = await _QuestionManager.GetQuestion(id);

            patch.ApplyTo(question);
            return(await _QuestionManager.UpdateQuestion(question));
        }
Esempio n. 2
0
 public IActionResult EditQuestion(QuestionDTO question)
 {
     if (ModelState.IsValid)
     {
         try
         {
             questionManager.UpdateQuestion(question);
             return(RedirectToAction("EditQuestions", new { @id = question.TestId }));
         }
         catch (Exception ex)
         {
             ModelState.AddModelError(string.Empty, ex.Message);
         }
     }
     return(View("_EditQuestion", question));
 }
Esempio n. 3
0
        public async Task <JsonResult> PostUpdateQuestion(int id, int questionId, [FromBody] Question question)
        {
            var result = await questionManager.UpdateQuestion(Token.UserId, id, questionId, question);

            switch (result.Status)
            {
            case SaveQuizResultStatus.NotAuthorized:
                return(ControllerHelper.CreateErrorResponse(HttpStatusCode.Unauthorized, "Unauthorized"));

            case SaveQuizResultStatus.GeneralError:
                return(ControllerHelper.CreateErrorResponse(HttpStatusCode.NotAcceptable, "GeneralError"));

            default:
                return(ControllerHelper.CreateResponse(result.Result));
            }
        }