Esempio n. 1
0
        public async Task<ActionResult> Statistics()
        {
            var db = new TriviaContext();
            var statisticsService = new StatisticsService(db);

            return View(await statisticsService.GenerateStatistics());
        }
 public TriviaController()
 {
     this.db = new TriviaContext();
     this.questionsService = new QuestionsService(db);
     this.answersService = new AnswersService(db);
     this.statisticsService = new StatisticsService(db);
 }
        public async Task<IHttpActionResult> Post(TriviaAnswer answer)
        {
            if (!ModelState.IsValid)
            {
                return this.BadRequest(this.ModelState);
            }

            answer.UserId = User.Identity.Name;

            var isCorrect = await this.StoreAsync(answer);

            var statisticsService = new StatisticsService(this.db);
            await statisticsService.NotifyUpdates();

            return this.Ok<bool>(isCorrect);
        }
 public StatisticsController()
 {
     this.db = new TriviaContext();
     this.statisticsService = new StatisticsService(db);
 }