Ejemplo n.º 1
0
        public ActionResult AddSurveyCompletion(CreateCompletionDTO completion)
        {
            var survey        = _surveyRepository.GetById(completion.SurveyId);
            var newCompletion = new Completion
                                (
                survey: survey,
                answers: _mapper.Map <List <Answer> >(completion.Answers),
                completingUserId: completion.CompletingUserId
                                );

            newCompletion.SetCompletionDateNow();

            survey.AddCompletion(newCompletion);
            _surveyRepository.Update(survey);
            _surveyRepository.Save();

            _surveyRepository.GetById(survey.Id);
            return(CreatedAtAction(nameof(GetCompletion), new { completionId = newCompletion.Id }, _mapper.Map <CompletionDTO>(newCompletion)));
        }