public void AddMatchPlayer(long matchId, MatchPlayer matchPlayer)
        {
            matchPlayer.match_id = matchId;
            matchPlayer.account_id = GetAccountId(matchPlayer.account_id);
            _matchPlayerAbilityRepository.AddMatchPlayerAbilities(matchPlayer);

            var matchPlayerItemRepository = new MatchPlayerItemRepository(matchPlayer, _db);
            matchPlayerItemRepository.AddMatchPlayerItems();

            _db.MatchPlayers.AddOrUpdate(matchPlayer);
        }
 public void AddMatchPlayerAbilities(MatchPlayer matchPlayer)
 {
     if (matchPlayer.ability_upgrades != null)
     {
         foreach (var ability in matchPlayer.ability_upgrades)
         {
             ability.match_id = matchPlayer.match_id;
             ability.account_id = matchPlayer.account_id;
             ability.player_slot = matchPlayer.player_slot;
             _db.MatchPlayerAbilities.AddOrUpdate(ability);
         }
     }
 }
        public void CompleteMatchPlayer(MatchPlayer matchPlayer)
        {
            var heroId = matchPlayer.hero_id;
            var hero = _db.Heroes.First(h => h.id == heroId);
            matchPlayer.hero = hero;

            var accountId = matchPlayer.account_id;
            var playerInfo = _db.Players.FirstOrDefault(p => p.account_id == matchPlayer.account_id);
            matchPlayer.playerInformation = playerInfo;

            var matchPlayerItemRepository = new MatchPlayerItemRepository(matchPlayer,_db);
            var items = matchPlayerItemRepository.GetItems();
            matchPlayer.matchPlayerItems = items;

            var matchPlayerAbilities = _db.MatchPlayerAbilities.Where(mpa => mpa.account_id == matchPlayer.account_id
                                                                          && mpa.match_id == matchPlayer.match_id
                                                                          && mpa.player_slot == matchPlayer.player_slot);
            matchPlayer.ability_upgrades = matchPlayerAbilities.ToList();
        }
 public MatchPlayerItemRepository(MatchPlayer matchPlayer, AppHarborDB db)
 {
     _matchPlayer = matchPlayer;
     _db = db;
 }