Ejemplo n.º 1
0
        public async Task <IActionResult> PostAsync([FromBody] ResultViewModel model)
        {
            if (model == null)
            {
                return(new StatusCodeResult(500));
            }

            if (!await ResultService.Exists(model.QuizId))
            {
                return(NotFound(new { Error = String.Format("Result ID {0} has not been found", model.Id) }));
            }

            if (!await QuizService.Exists(model.QuizId))
            {
                return(NotFound(new { Error = String.Format("Quiz ID {0} has not been found", model.QuizId) }));
            }

            ResultDetailsServiceModel result = await ResultService.Update(
                model.Id,
                model.Text,
                model.MinValue,
                model.MaxValue,
                model.QuizId);

            return(new JsonResult(Mapper.Map <ResultDetailsServiceModel, ResultViewModel>(result), JsonSettings));
        }