Beispiel #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'
        }
Beispiel #2
0
 public Account Get(string userName)
 {
     try
     {
         IAccountDAL dal     = AccountFactory.GetAccountDAL();
         var         account = dal.GetAccount(userName);
         return(account);
     }
     catch
     {
         return(null);
     }
 }
Beispiel #3
0
 public void ValidateLogin(string username, string password)
 {
     account.GetAccount(username, password);
 }