public ScoreboardView()
        {
            this.viewModel   = new ScoreboardViewModel();
            this.DataContext = this.viewModel;

            this.InitializeComponent();
        }
        public ActionResult Scoreboard(int?id)
        {
            if (id == null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            int            assignmentId = Convert.ToInt32(id);
            assignment     assign       = assignmentService.GetAssignmentById(assignmentId);
            List <team>    teams        = scoreboardService.GetTeamsOfAssignment(assignmentId);
            List <problem> probs        = problmService.GetProblemsOfAssignment(assignmentId);

            List <ProblemSuccessHolder> tableData = new List <ProblemSuccessHolder>();

            foreach (var team in teams)
            {
                List <bool> success = new List <bool>();
                foreach (var prob in probs)
                {
                    success.Add(scoreboardService.CheckIfDone(prob.id, team.id));
                }
                tableData.Add(new ProblemSuccessHolder {
                    name = team.name, success = success
                });
            }
            ScoreboardViewModel info = new ScoreboardViewModel {
                assignment = assign, probs = probs.Count, tableData = tableData
            };

            return(View(info));
        }
Example #3
0
        public async Task <ScoreboardViewModel> GetScoreboardAsync(IEnumerable <int> weeks)
        {
            // we can't open multiple connections to the database concurrently,
            // which would be necessary if we wanted to process the users in
            // asynchronously because we call GetUserPointsForWeeksAsync. so,
            // we first collect the list of users with rosters into a list,
            // create an empty collection for the scoreboard rows, then finally
            // sequentially iterate through the user list and fetch their
            // points by week (in a blocking manner) and add the new scoreboard
            // row to a list.
            // see https://docs.microsoft.com/en-us/ef/core/miscellaneous/configuring-dbcontext#avoiding-dbcontext-threading-issues
            var usersWithRosters = await _dbContext.Users
                                   .Where(u => _dbContext.FantasyRosters.Where(r => r.OwnerId == u.Id).SingleOrDefault() != null)
                                   .ToListAsync();

            List <ScoreboardRow> rows = new List <ScoreboardRow>(usersWithRosters.Count);

            foreach (var user in usersWithRosters)
            {
                var pointsByWeek = GetUserPointsForWeeksAsync(user, weeks)
                                   .Result
                                   .ToDictionary(item => item.Week, item => item.Points);

                rows.Add(new ScoreboardRow
                {
                    Username     = user.UserName,
                    PointsByWeek = pointsByWeek
                });
            }
            var scoreboard = new ScoreboardViewModel {
                Rows = rows
            };

            return(scoreboard);
        }
Example #4
0
        public TeamViewModel(int teamIndex, ScoreboardViewModel scoreboard1, ScoreboardViewModel scoreboard2,
                             WordGameViewModel wordGameViewModel, BingoCardSettings bingoCardSettings, Random random,
                             AudioPlaybackEngine audioPlaybackEngine, ActiveSceneContainer activeSceneContainer)
        {
            _teamIndex           = teamIndex;
            _bingoCardSettings   = bingoCardSettings;
            _random              = random;
            _audioPlaybackEngine = audioPlaybackEngine;
            Scoreboard1          = scoreboard1;
            Scoreboard2          = scoreboard2;
            WordGameViewModel    = wordGameViewModel;
            ActiveSceneContainer = activeSceneContainer;

            if (teamIndex == 0)
            {
                this.WhenAnyValue(x => x.ActiveSceneContainer.IsTeam1Active).ToPropertyEx(this, x => x.OnAir);
            }
            else
            {
                this.WhenAnyValue(x => x.ActiveSceneContainer.IsTeam2Active).ToPropertyEx(this, x => x.OnAir);
            }


            CreateNewBingoCard();
        }
        public ActionResult AddScore()
        {
            ScoreboardViewModel scoreboardViewModel = new ScoreboardViewModel();
            IEnumerable <Game>  games = gameTable.GetAll();

            scoreboardViewModel.listOfGames = games.ToList();
            return(View(scoreboardViewModel));
        }
Example #6
0
        public async Task <IActionResult> Index()
        {
            var model = new ScoreboardViewModel(
                Quests: await _questRepository.GetQuests(),
                Teams: await _scoringRepository.GetHighSocres()
                );

            return(View(model));
        }
Example #7
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            DataContext = new ScoreboardViewModel((IEnumerable <Player>)e.Parameter);

            SystemNavigationManager systemNavigationManager = SystemNavigationManager.GetForCurrentView();

            systemNavigationManager.BackRequested += ScoreboardView_BackRequestedAsync;
            systemNavigationManager.AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible;
        }
Example #8
0
        }                                                           // TODO move to model class


        public GameViewModel(Settings settings, GameState state, AudioPlaybackEngine audioPlaybackEngine, ActiveSceneContainer activeSceneContainer)
        {
            Random random = new Random();
            var    audioPlaybackEngine1 = audioPlaybackEngine;

            ScoreBoardTeam1   = new ScoreboardViewModel(state.Team1, HorizontalAlignment.Left);
            ScoreBoardTeam2   = new ScoreboardViewModel(state.Team2, HorizontalAlignment.Right);
            WordGameViewModel = new WordGameViewModel(state, audioPlaybackEngine);

            var bingoCardSettingsTeam1 = new BingoCardSettings(true, settings.ExcludedBallNumbersEven);
            var bingoCardSettingsTeam2 = new BingoCardSettings(false, settings.ExcludedBallNumbersOdd);

            Team1ViewModel = new TeamViewModel(0, ScoreBoardTeam1, ScoreBoardTeam2, WordGameViewModel, bingoCardSettingsTeam1, random, audioPlaybackEngine1, activeSceneContainer);
            Team2ViewModel = new TeamViewModel(1, ScoreBoardTeam1, ScoreBoardTeam2, WordGameViewModel, bingoCardSettingsTeam2, random, audioPlaybackEngine1, activeSceneContainer);

            CountDownStarted = ReactiveCommand.Create(() => new Unit());

            this.WhenAnyValue(x => x.WordGameViewModel.BoardViewModel).Where(x => x != null).Subscribe(x =>
            {
                WordGameStarted();
            });
        }
Example #9
0
        public GamesViewModel()
        {
            LoginViewModel      = new LoginViewModel();
            ScoreboardViewModel = new ScoreboardViewModel();
            TicTacToeViewModel  = new TicTacToeViewModel();
            PairGameViewModel   = new PairGameViewModel();
            RatingViewModel     = new RatingViewModel();
            SnakeViewModel      = new SnakeViewModel();
            DoorsGameViewModel  = new DoorsGameViewModel();
            MoneyViewModel      = new MoneyViewModel();

            _playerManager = new PlayerManager();


            NewGameCommand = new RelayCommand(param => StartGame((string)param));

            ShopCommand = new RelayCommand(param =>
            {
                ShopWindow shopWindow = new ShopWindow();
                shopWindow.ShowDialog();
            });

            ScoreboardCommand = new RelayCommand(param =>
            {
                ScoreboardViewModel.Refresh();
                ScoreboardView scoreboardView = new ScoreboardView();
                scoreboardView.ShowDialog();
            });

            RatingCommand = new RelayCommand(param =>
            {
                RatingView ratingView = new RatingView();
                ratingView.ShowDialog();
            });

            PlayerEditCommand = new RelayCommand(param =>
            {
                EditView editView = new EditView();
                editView.ShowDialog();
            });

            AddMoneyCommand = new RelayCommand(param =>
            {
                MoneyView moneyView = new MoneyView();
                moneyView.ShowDialog();
            });

            StartGameTestingCommand = new RelayCommand(param => { StartGameTesting((string)param); });


            BuyItemCommand = new RelayCommand(param =>
            {
                if (int.Parse(param.ToString()) > Money)
                {
                    MessageBox.Show("You do not have enough to buy this game.\n Consider adding money to your balance.",
                                    "Message", MessageBoxButton.OK);
                }
                else
                {
                    _playerManager.AddMoney(LoginViewModel.Player.Id, -int.Parse(param.ToString()));
                    Money = Money;
                }
            });
        }
 public ScoreboardPage()
 {
     InitializeComponent();
     BindingContext = viewModel = new ScoreboardViewModel();
 }