예제 #1
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'
        }
예제 #2
0
        public IActionResult Create(Account account)
        {
            IAccountDAL dal = AccountFactory.GetAccountDAL();

            dal.CreateAccount(account);
            return(Accepted());
        }
예제 #3
0
 public Account Get(string userName)
 {
     try
     {
         IAccountDAL dal     = AccountFactory.GetAccountDAL();
         var         account = dal.GetAccount(userName);
         return(account);
     }
     catch
     {
         return(null);
     }
 }