public async Task HandleAsync(RegisterUser command) { var tournamentUserRow = new TournamentsUsers() { TournamentId = command.TournamentId, UserId = command.UserId }; await _tournamentsUsersRepository.Add(tournamentUserRow); await _tournamentsUsersRepository.SaveChanges(); }
public async Task Calculate(int tournamentId) { var usersExercises = await _exercisesUsersRepository.GetByTournamentId(tournamentId); var usersTournaments = await _tournamentsUsersRepository.GetByTournamentId(tournamentId); Parallel.ForEach(usersExercises, (current) => { current.IsCorrect = IsAnswerCorrect(current.Exercise.Answer, current.UserAnswer); }); GetPlaces(usersTournaments, usersExercises); await _tournamentsUsersRepository.SaveChanges(); await _exercisesUsersRepository.SaveChanges(); }