Esempio n. 1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,CorrectPicks")] BracketModel bracketModel)
        {
            if (id != bracketModel.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(bracketModel);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BracketModelExists(bracketModel.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(bracketModel));
        }
        public async Task <IActionResult> PickGame(int homeId, int awayId, [Bind("Id,HomeTeam,AwayTeam,HomeTeamId,AwayTeamId,HomeScore,AwayScore,BracketId,BracketPosition,Prediction")] GameModel gameModel)
        {
            if (ModelState.IsValid)
            {
                var bracket = _context.BracketModel.Include(b => b.Games).Where(b => b.Id == gameModel.BracketId).Single();
                bracket.Games.Append(gameModel);
                _context.Update(bracket);
                _context.Add(gameModel);
                await _context.SaveChangesAsync();

                if (gameModel.BracketPosition < 62)
                {
                    int nextGame = gameModel.BracketPosition.Value + 1;
                    return(RedirectToAction("Pick", "Bracket", new { bracketId = gameModel.BracketId.Value, bracketPosition = nextGame }));
                }
                return(RedirectToAction("Index", "Bracket", new { area = "" }));
            }
            return(View(gameModel));
        }
Esempio n. 3
0
        // GET: Team/GetStats
        public async Task <IActionResult> GetStats()
        {
            var teams = _context.TeamModel.ToList();

            foreach (var team in teams)
            {
                string url = "http://stats.clinetechnologysolutions.com/get-stats/" + team.TeamId.ToString();
                using (HttpClient client = new HttpClient())
                {
                    var response = JsonConvert.DeserializeObject <Dictionary <string, decimal> >(await client.GetStringAsync(url));
                    team.AvgAst      = response["Ast"];
                    team.AvgBlk      = response["Blk"];
                    team.AvgDefReb   = response["DefReb"];
                    team.AvgOffReb   = response["OffReb"];
                    team.AvgOppScore = response["OppScore"];
                    team.AvgScore    = response["Score"];
                    team.AvgStl      = response["Stl"];
                }
                _context.Update(team);
            }
            await _context.SaveChangesAsync();

            return(RedirectToAction(nameof(Index)));
        }