コード例 #1
0
ファイル: TeamController.cs プロジェクト: uptosky/FreeFootie
        // POST api/<controller>
        public void PostTeam(Team team)
        {
            try
            {
                string connectionString = Properties.Settings.Default.FreeFootieConnectionString;
                using (FreeFootieDataContext myData = new FreeFootieDataContext(connectionString))
                {
                    using (TransactionScope myScope = new TransactionScope())
                    {
                        team newTeam = new team();
                        var newID = (from c in myData.teams
                                     select c.id).Max();
                        newTeam.id = newID + 1;
                        newTeam.name = team.name;
                        newTeam.coach = team.coach;
                        newTeam.losses = team.loses;
                        newTeam.wins = team.wins;
                        newTeam.ties = team.ties;
                        newTeam.phone = team.phone;
                        newTeam.schoolID = team.school;

                        myData.teams.InsertOnSubmit(newTeam);

                        foreach (int playerID in team.palyers)
                        {
                            teamPlayer newTeamPlayer = new teamPlayer();
                            newTeamPlayer.teamID = newTeam.id;
                            newTeamPlayer.playerID = playerID;

                            myData.teamPlayers.InsertOnSubmit(newTeamPlayer);
                        }

                        myData.SubmitChanges();
                        myScope.Complete();
                    }
                }
            }
            catch (Exception ex)
            {
                Common.ErrorCatch(ex, "TeamController.PostTeam");

            }
        }
コード例 #2
0
		private void detach_teamPlayers(teamPlayer entity)
		{
			this.SendPropertyChanging();
			entity.player = null;
		}
コード例 #3
0
		private void attach_teamPlayers(teamPlayer entity)
		{
			this.SendPropertyChanging();
			entity.player = this;
		}
コード例 #4
0
 partial void DeleteteamPlayer(teamPlayer instance);
コード例 #5
0
 partial void UpdateteamPlayer(teamPlayer instance);
コード例 #6
0
 partial void InsertteamPlayer(teamPlayer instance);