示例#1
0
        // 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_teams(team entity)
		{
			this.SendPropertyChanging();
			entity.pool = null;
		}
示例#3
0
		private void attach_teams(team entity)
		{
			this.SendPropertyChanging();
			entity.pool = this;
		}
示例#4
0
 partial void Deleteteam(team instance);
示例#5
0
 partial void Updateteam(team instance);
示例#6
0
 partial void Insertteam(team instance);