예제 #1
0
        private void LoadMatchesToGrid()
        {
            //GetCompTeams
            var tList = teamService.GetCompetitionTeams(comboBoxCompetionId);

            //GetMatches
            var mList = matchService.GetMatchesByCompetitionFixture(comboBoxCompetionId, numericBoxFixtureId);

            if (tList != null && tList.Count() > 0 && mList != null && mList.Count() > 0)
            {
                int idx = 1;
                foreach (var itemMatch in mList.OrderBy(x => x.Order))
                {
                    MatchesHFModel match = new MatchesHFModel()
                    {
                        Order        = idx,
                        MatchId      = itemMatch.MatchId,
                        HomeTeamId   = itemMatch.HomeTeamId,
                        HomeTeam     = teamService.GetTeamName(itemMatch.HomeTeamId),
                        HomeGoals    = itemMatch.HalfHomeGoals.HasValue? itemMatch.HalfHomeGoals.Value : itemMatch.HomeGoals,
                        MinHomeGoals = itemMatch.HomeGoals,
                        AwayTeamId   = itemMatch.AwayTeamId,
                        AwayTeam     = teamService.GetTeamName(itemMatch.AwayTeamId),
                        AwayGoals    = itemMatch.HalfAwayGoals.HasValue ? itemMatch.HalfAwayGoals.Value : itemMatch.AwayGoals,
                        MinAwayGoals = itemMatch.AwayGoals,
                    };

                    matchItems.Add(match);
                    idx++;
                }
            }
        }
예제 #2
0
        private void ButtonSaveSingleMatch_Click(object sender, RoutedEventArgs e)
        {
            if (IsUiTeamsLocked)
            {
                return;
            }

            MatchesHFModel item = (sender as Button).DataContext as MatchesHFModel;

            if (item != null)
            {
                //VALIDATIONS
                if (item.HomeTeamId == 0)
                {
                    NotificationHelper.notifier.ShowCustomMessage("No jogo nº " + item.Order.ToString() +
                                                                  " falta selecionar a equipa de casa");
                    return;
                }
                else if (item.AwayTeamId == 0)
                {
                    NotificationHelper.notifier.ShowCustomMessage("No jogo nº " + item.Order.ToString() +
                                                                  " falta selecionar a equipa de fora");
                    return;
                }

                new Thread(() =>
                {
                    UtilsNotification.StartLoadingAnimation();
                    LockAddMatchesUI();

                    //save data
                    var resultado = matchService.UpdateMatchHalfTime(item.MatchId, item.HomeGoals, item.AwayGoals);

                    if (resultado != Commons.OperationTypeValues.Error)
                    {
                        //update model
                        item.ButtonSaveVisibility = Visibility.Collapsed;
                        item.ImageDoneVisibility  = Visibility.Visible;

                        string opType = resultado == Commons.OperationTypeValues.Create ? "registada" :
                                        resultado == Commons.OperationTypeValues.Edit ? "editada" : "inalterada (erro)";
                        NotificationHelper.notifier.ShowCustomMessage("2ª parte do jogo nº " + item.Order + " foi " + opType + " com sucesso!");
                    }
                    else
                    {
                        NotificationHelper.notifier.ShowCustomMessage("Ocorreu um erro ao registar a 2ª parte do jogo nº " + item.Order);
                    }

                    UnlockAddMatchesUI();
                    UtilsNotification.StopLoadingAnimation();
                }).Start();
            }
        }