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' }
public IActionResult Create(Account account) { IAccountDAL dal = AccountFactory.GetAccountDAL(); dal.CreateAccount(account); return(Accepted()); }
public Account Get(string userName) { try { IAccountDAL dal = AccountFactory.GetAccountDAL(); var account = dal.GetAccount(userName); return(account); } catch { return(null); } }