Example #1
0
        // Create/Update/Delete methods

        public async Task <Question> CreateQuestionAsync(Question question, string userId)
        {
            var access = await _quizzesRepository.HaveWriteAccessToQuiz(userId, question.QuizId);

            if (!access)
            {
                return(null);
            }

            var creationTime = CurrentTime;

            question.CreationTime = creationTime;

            var questionVersion = new QuestionVersion {
                CreationTime = creationTime,
                Value        = question.Value
            };

            question.Versions.Add(questionVersion);
            question.FlatVersionProps();

            await _questionsRepository.Create(question);

            return(await Context.SaveChangesAsync() > 0
                ? question
                : null);
        }
 public Question Create(Question questionData)
 {
     questionData.Id = Guid.NewGuid().ToString();
     questionData.QuestionCreated = DateTime.Now;
     _repo.Create(questionData);
     return(questionData);
 }
        public Question AddQuestion(Question questionData)
        {
            questionData.Id        = Guid.NewGuid().ToString();
            questionData.DateAsked = DateTime.Now;
            var postedQuestion = _repo.Create(questionData);

            return(postedQuestion);
        }
        /*
         * /// <summary>
         * /// Permet d'update une question
         * /// </summary>
         * /// <param name="id"></param>
         * /// <param name="obj"></param>
         * /// <returns>une question modifié (DTO) </returns>
         * internal FindQuestionsDto PutQuestion(int id, CreatedQuestionDTO obj)
         * {
         *  Question questionModels = transformsDtoToModel(obj);
         *  Question questionUpdate = questionsRepository.Update(id, questionModels);
         *  return TransformsModelToDTO(questionUpdate);
         * }
         */

        /// <summary>
        /// Générer une question dans la bdd
        /// </summary>
        /// <param name="obj"></param>
        /// <returns>la question créée</returns>
        internal FindQuestionsDto PostQuestion(CreatedQuestionDTO obj)
        {
            // Création de la réponse

            FindAnswerDto answer = this.AnswerServices.PostAnswer(obj.Answer);

            // Création de la question
            Question questionModel   = transformsDtoToModel(obj, (int)answer.IdAnswer);
            Question questioncreated = questionsRepository.Create(questionModel);

            return(TransformsModelToDTO(questioncreated, answer));
        }
 public Question AddQuestion(Question questionData)
 {
     questionData.Id = Guid.NewGuid().ToString();
     _repo.Create(questionData);
     return(questionData);
 }
Example #6
0
 internal Question Create(Question newQuestion)
 {
     newQuestion.Id = _repo.Create(newQuestion);
     return(newQuestion);
 }