private void UploadPlayerInfoToDatabase()
 {
     using (var context = new FantasyFootballEF())
     {
         if (_playerInTeamCount == null)
         {
             return;
         }
         var now = DateTime.Now;
         foreach (var playerCount in _playerInTeamCount)
         {
             var selectedPlayer =
                 context.player.Where(pl => pl.id == playerCount.Key).Select(pl => pl).FirstOrDefault();
             if (selectedPlayer == null)
             {
                 continue;
             }
             context.player_in_teams_info.Add(new player_in_teams_info
             {
                 count     = playerCount.Value,
                 date      = now,
                 player_id = playerCount.Key
             });
         }
         context.SaveChanges();
     }
 }
 private void UploadTeamInfoToDatabase()
 {
     using (var context = new FantasyFootballEF())
     {
         if (_teamIdDictionary == null || _teamIdDictionary.Count == 0)
         {
             return;
         }
         foreach (var team in _teamIdDictionary)
         {
             var teamId       = team.Key;
             var teamPlace    = team.Value;
             var selectedTeam = context.team.FirstOrDefault(t => t.id == teamId);
             if (selectedTeam == null)
             {
                 context.team.Add(new team
                 {
                     id    = teamId,
                     place = teamPlace
                 });
             }
             else
             {
                 var previousTeamWithThisPlace = context.team.Where(p => p.place == teamPlace).Select(p => p);
                 foreach (var prevTeam in previousTeamWithThisPlace)
                 {
                     prevTeam.place = 0;
                 }
                 selectedTeam.place = teamPlace;
             }
         }
         context.SaveChanges();
     }
 }