Exemple #1
0
    public void UpdatePlayerChampionships(Player player)
    {
        bool flag = false;
        foreach (Championship c in db.Championships)
        {
            foreach (PlayerToChampionship ctp in db.PlayerToChampionships)
            {
                if (c.Id == ctp.Championship_Id)
                {
                    flag = true;
                    break;
                }
            }
            if (!flag)
            {
                PlayerToChampionship ptc = new PlayerToChampionship();
                ptc.Championship_Id = c.Id;
                ptc.Player_Id = player.Id;
                db.PlayerToChampionships.InsertOnSubmit(ptc);
                db.SubmitChanges();
            }

        }
    }
Exemple #2
0
    public void AddPlayerToChamp(Player player, int champId)
    {
        var x =
            (from p in db.PlayerToChampionships
            where p.Player_Id == player.Id && p.Championship_Id == champId
            select p).SingleOrDefault();

        if(x == null)
        {
            PlayerToChampionship playerToChamp = new PlayerToChampionship();
            int id = Convert.ToInt32(x);
            playerToChamp.Player_Id = player.Id;
            playerToChamp.Championship_Id = champId;
            db.PlayerToChampionships.InsertOnSubmit(playerToChamp);
            db.SubmitChanges();
        }
    }
 partial void UpdatePlayerToChampionship(PlayerToChampionship instance);
 partial void DeletePlayerToChampionship(PlayerToChampionship instance);
 partial void InsertPlayerToChampionship(PlayerToChampionship instance);