Exemple #1
0
        public async Task <IActionResult> Index()
        {
            await matchesService.DeleteOldMatchesAsync();

            await matchesService.CheckAndGiveResultsToMatchesAsync();

            var matches = await matchesService.GetUnfinishedMatchesAsync();

            var matchViewModels = new List <MatchViewModel>();

            foreach (var match in matches)
            {
                var matchViewModel = new MatchViewModel
                {
                    FirstTeamName  = match.MatchTeams.ToArray()[0].Team.Name,
                    SecondTeamName = match.MatchTeams.ToArray()[1].Team.Name,
                    MatchId        = match.Id,
                    StartingTime   = match.StartingTime
                };

                matchViewModels.Add(matchViewModel);
            }



            return(View(matchViewModels));
        }