public async Task <IActionResult> Get() { try { var quizzen = await quizRepo.GetAllAsync(); var quizzenDTO = mapper.Map <IEnumerable <QuizDTO> >(quizzen); return(Ok(quizzenDTO)); } catch (Exception ex) { logger.LogError(ex.Message); return(BadRequest()); } }
public async Task <IActionResult> TopScores() { try { var quizzen = await quizRepo.GetAllAsync(); return(View(quizzen)); } catch (Exception ex) { logger.LogError(ex.Message); return(View("Error", new ErrorViewModel() { RequestId = HttpContext.TraceIdentifier })); } }
public async Task <IActionResult> Index() { try { var quizzes = await _quizRepo.GetAllAsync(); var quizVMs = new List <QuizVM>(); foreach (var quiz in quizzes) { var quizid = quiz.Id; var userid = User.FindFirstValue(ClaimTypes.NameIdentifier); var foundUserQuiz = await _userQuizRepo.GetUserQuizByMaximumScore(quizid, userid); var quizVM = new QuizVM() { Quiz = quiz }; if (foundUserQuiz != null) { quizVM.BestScore = foundUserQuiz.EndScore; quizVM.BestScoreDate = foundUserQuiz.Timestamp; } quizVMs.Add(quizVM); } return(View(quizVMs)); } catch (Exception ex) { _logger.LogError(ex.Message); return(View("Error", new ErrorViewModel() { RequestId = HttpContext.TraceIdentifier })); } }
public async Task <IActionResult> Index() { var allQuizzes = await quizRepo.GetAllAsync(); return(View(allQuizzes)); }