예제 #1
0
        public async Task<IHttpActionResult> Update(QuestionDTO questionDto)
        {
            string token = Request.Headers.GetValues("Authorization").FirstOrDefault();
            _questionProvider.UpdateQuestion(questionDto);

            Logger.Logger.Instance.LogAction(LoggerHelper.GetActionString(TokenHelper.GetFromToken(token, "username"), "Question Updated "));
            return Content(HttpStatusCode.OK, "Updated successfully");
        }
예제 #2
0
        public int CreateQuestion(QuestionDTO dtoQuestion)
        {
            var question = Mapper.Map<Question>(dtoQuestion);
            question.Module = _moduleRepository.Get(u => u.ModuleId == dtoQuestion.ModuleId);
            //var test = _testRepository.Get(u => u.TestId == dtoQuestion.TestId);

            //test.Questions.Add(question);
            _questionRepository.Add(question);
            _questionRepository.SaveChanges();
//            _testRepository.SaveChanges();
            return question.QuestionId;
        }
예제 #3
0
 public void UpdateQuestion(QuestionDTO dtoQuestion)
 {
     var question = _questionRepository.Get(u => u.QuestionId == dtoQuestion.QuestionId);
     question.Score = dtoQuestion.Score;
     question.Text = dtoQuestion.Text;
     _questionRepository.SaveChanges();
 }