Ejemplo n.º 1
0
        public IActionResult Create(Question question)
        {
            IQuestionDAL dal = QuestionFactory.GetQuestionDAL();

            dal.Create(question);
            return(Accepted());
        }
Ejemplo n.º 2
0
        public string Validate(int id, string answer, string userName)
        {
            IQuestionDAL questionDal = QuestionFactory.GetQuestionDAL();
            Question     question    = questionDal.GetQuestion(id);

            if (!questionDal.QuestionIsAlreadyAnswered(userName, id))
            {
                if (answer == question.CorrectAnswer)
                {
                    IAccountDAL accountDAL = AccountFactory.GetAccountDAL();
                    Account     account    = accountDAL.GetAccount(userName);
                    accountDAL.AddScore(account, 10);
                    questionDal.QuestionAnswered(userName, id);
                    return("Question answered correctly");
                }
                else
                {
                    questionDal.QuestionAnswered(userName, id);
                    return("Question answered incorrectly");
                }
            }
            else
            {
                return("Question already answered");
            }

            // id = 2
            // answer = 'correct'
        }
Ejemplo n.º 3
0
 public List <Question> Get(int id)
 {
     try
     {
         IQuestionDAL dal      = QuestionFactory.GetQuestionDAL();
         var          question = dal.GetArticleQuestions(id);
         return(question);
     }
     catch
     {
         return(null);
     }
 }
Ejemplo n.º 4
0
 public QuestionBLL()
     : base(_Type)
 {
     this._Dal = base.CurrentDAL as IQuestionDAL;
 }
 public QuestionService(IQuestionDAL questionDAL)
 {
     this.questionDAL = questionDAL;
 }