Пример #1
0
        public IActionResult AddPlayer(Player player, string TeamId)
        {
            var id = int.Parse(TeamId);

            player.Team             = _db.Teams.FirstOrDefault(t => t.TeamId == id);
            player.FreeAgent        = false;
            _db.Entry(player).State = EntityState.Modified;
            _db.SaveChanges();
            return(RedirectToAction("Index", "League"));
        }
Пример #2
0
 public static void AddTeam(SportsTeam sportsTeam)
 {
     using (var context = new FantasyFootballContext())
     {
         context.SportsTeam.Add(sportsTeam);
         context.SaveChanges();
     }
 }
Пример #3
0
 public static void AddPlayer(BasePlayer player)
 {
     using (var context = new FantasyFootballContext())
     {
         context.BasePlayer.Add(player);
         context.SaveChanges();
     }
 }
Пример #4
0
        public async Task <IActionResult> Create(League league)
        {
            var userId      = this.User.FindFirst(ClaimTypes.NameIdentifier)?.Value;
            var currentUser = await _userManager.FindByIdAsync(userId);

            league.User = currentUser;
            _db.Leagues.Add(league);
            _db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #5
0
 public static void ClearDatabase()
 {
     using (var context = new FantasyFootballContext())
     {
         context.BasePlayer.RemoveRange(context.BasePlayer.ToList());
         context.Player.RemoveRange(context.Player.ToList());
         //context.SportsTeam.RemoveRange(context.SportsTeam.ToList());
         context.SaveChanges();
     }
 }
Пример #6
0
        public async Task <IActionResult> Create(Team team)
        {
            var userId      = this.User.FindFirst(ClaimTypes.NameIdentifier)?.Value;
            var currentUser = await _userManager.FindByIdAsync(userId);

            var selectedLeague = _db.Leagues.FirstOrDefault(league => league.LeagueId == team.LeagueId);

            selectedLeague.TeamCount += 1;
            team.User = currentUser;
            _db.Entry(selectedLeague).State = EntityState.Modified;
            _db.Teams.Add(team);
            _db.SaveChanges();
            return(RedirectToAction("Index", "League"));
        }