Ejemplo n.º 1
0
 public void UpdateAnswer(AnswerDTO dtoAnswer)
 {
     var answer = _answerRepository.Get(t => t.AnswerId == dtoAnswer.AnswerId);
     answer.Text = dtoAnswer.Text;
     answer.IsCorrect = dtoAnswer.IsCorrect;
     _answerRepository.SaveChanges();
 }
Ejemplo n.º 2
0
        public async Task<IHttpActionResult> Update(AnswerDTO answerDto)
        {
            string token = Request.Headers.GetValues("Authorization").FirstOrDefault();
            _answerProvider.UpdateAnswer(answerDto);

            Logger.Logger.Instance.LogAction(LoggerHelper.GetActionString(TokenHelper.GetFromToken(token, "username"), "Answer updated"));
            return Content(HttpStatusCode.OK, "Updated successfully");
        }
Ejemplo n.º 3
0
        public void CreateAnswer(AnswerDTO dtoAnswer)
        {
            var answer = Mapper.Map<Answer>(dtoAnswer);
            var question = _questionRepository.Get(u => u.QuestionId == dtoAnswer.QuestionId);
            if (question == null)
            {
                throw new Exception("Question was not found");
            }
            question.Answers.Add(answer);
            _answerRepository.Add(answer);

            _questionRepository.SaveChanges();
        }