public async Task <IActionResult> Create(GameCreateViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                _context.Add(viewModel.gameModel);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(viewModel));
        }
Beispiel #2
0
        public async Task <IActionResult> Create([Bind("Id,Name")] BracketModel bracketModel)
        {
            bracketModel.Games        = new List <GameModel>(63);
            bracketModel.CorrectPicks = 0;
            if (ModelState.IsValid)
            {
                _context.Add(bracketModel);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Pick", "Bracket", new { bracketId = bracketModel.Id, bracketPosition = 0 }));
            }
            return(View(bracketModel));
        }
Beispiel #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)));
        }