public QuizRoundDto AddRoundToQuiz(QuizRoundDto quizDto, int quizId) { var round = _roundRepository.Add(new QuizRound { QuizId = quizId, RoundName = quizDto.RoundName, MaxRoundScore = quizDto.MaxScorePerRound }).First(); _roundRepository.Save(); return(new QuizRoundDto { QuizId = round.QuizId, RoundName = round.RoundName, MaxScorePerRound = round.MaxRoundScore, Id = round.Id }); }
public IActionResult AddRound([FromBody] QuizRoundDto roundDto, int quizId) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var newRound = _quizRoundService.AddNewRound(roundDto, quizId, GetUserEmailFromToken()); if (newRound != null) { return(Ok(newRound)); } return(BadRequest("Something went wrong while adding the round to a quiz")); }
public QuizRoundDto AddNewRound(QuizRoundDto quizRoundDto, int quizId, string userEmail) { if (_quizService.GetQuiz(quizId) == null) { return(null); } var addedRound = _roundService.AddRoundToQuiz(quizRoundDto, quizId); var players = _roundService.GetPlayersFromARound(quizId).ToList(); _roundService.InsertUsersIntoTheRoundUserPoints(addedRound.Id, TransFormGetUserPointDtoToPlayerInQuizDto(players).ToList()); quizRoundDto.QuizId = quizId; quizRoundDto.Id = addedRound.Id; return(quizRoundDto); }