Esempio n. 1
0
        //// PUT api/<controller>/5
        //public void Put(int id, [FromBody]string value)
        //{
        //}
        // DELETE api/<controller>/5
        public void DeleteLocation(int id)
        {
            try
            {
                string connectionString = Properties.Settings.Default.FreeFootieConnectionString;
                using (FreeFootieDataContext myData = new FreeFootieDataContext(connectionString))
                {
                    using (TransactionScope myScope = new TransactionScope())
                    {
                        myData.locations.DeleteOnSubmit(myData.locations.Single(c => c.id == id));

                        myData.SubmitChanges();
                        myScope.Complete();
                    }
                }
            }
            catch (Exception ex)
            {
                Common.ErrorCatch(ex, "LocationController.DeleteLocation");
            }
        }
Esempio n. 2
0
        // POST api/<controller>
        public void PostLocation(Location location)
        {
            try
            {
                string connectionString = Properties.Settings.Default.FreeFootieConnectionString;
                using (FreeFootieDataContext myData = new FreeFootieDataContext(connectionString))
                {
                    using (TransactionScope myScope = new TransactionScope())
                    {
                        location newLocation = new location();
                        var newID = (from c in myData.locations
                                     select c.id).Max();
                        newLocation.id = newID + 1;
                        newLocation.name = location.name;
                        newLocation.latitude = location.latitude;
                        newLocation.longitude = location.longitude;

                        myData.locations.InsertOnSubmit(newLocation);
                        myData.SubmitChanges();
                        myScope.Complete();
                    }
                }
            }
            catch (Exception ex)
            {
                Common.ErrorCatch(ex, "LocationController.PostLocation");
            }
        }
Esempio n. 3
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");

            }
        }
Esempio n. 4
0
        // POST api/<controller>
        public void PostPool(Pool pool)
        {
            try
            {
                string connectionString = Properties.Settings.Default.FreeFootieConnectionString;
                using (FreeFootieDataContext myData = new FreeFootieDataContext(connectionString))
                {
                    using (TransactionScope myScope = new TransactionScope())
                    {
                        pool newPool = new pool();
                        var newID = (from c in myData.pools
                                     select c.id).Max();
                        newPool.id = newID + 1;
                        newPool.name = pool.name;

                        myData.pools.InsertOnSubmit(newPool);
                        myData.SubmitChanges();
                        myScope.Complete();
                    }
                }
            }
            catch (Exception ex)
            {
                Common.ErrorCatch(ex, "PoolController.PostPool");

            }
        }
Esempio n. 5
0
        // POST api/<controller>
        public void PostPlayer(Player player)
        {
            try
            {
                string connectionString = Properties.Settings.Default.FreeFootieConnectionString;
                using (FreeFootieDataContext myData = new FreeFootieDataContext(connectionString))
                {
                    using (TransactionScope myScope = new TransactionScope())
                    {
                        player newPalyer = new player();
                        var newID = (from c in myData.players
                                     select c.id).Max();
                        newPalyer.id = newID + 1;
                        newPalyer.name = player.name;
                        newPalyer.dob = Convert.ToDateTime(player.dob);
                        newPalyer.number = player.number;

                        myData.players.InsertOnSubmit(newPalyer);
                        myData.SubmitChanges();
                        myScope.Complete();
                    }
                }
            }
            catch (Exception ex)
            {
                Common.ErrorCatch(ex, "PlayerController.PostPlayer");
            }
        }
Esempio n. 6
0
        public void SetScore(int id, int homeTeamScore, int awayTeamScore)
        {
            try
            {
                string connectionString = Properties.Settings.Default.FreeFootieConnectionString;
                using (FreeFootieDataContext myData = new FreeFootieDataContext(connectionString))
                {
                    using (TransactionScope myScope = new TransactionScope())
                    {
                        game newGame = new game();
                        var theGame = (from c in myData.games
                                     where c.id == id
                                     select c).SingleOrDefault();

                        theGame.homeTeamScore = homeTeamScore;
                        theGame.awayTeamScore = awayTeamScore;

                        myData.SubmitChanges();
                        myScope.Complete();
                    }
                }
            }
            catch (Exception ex)
            {
                Common.ErrorCatch(ex, "GameController.PostGame");
            }
        }
Esempio n. 7
0
        // POST api/<controller>
        public void PostGame(Game game)
        {
            try
            {
                string connectionString = Properties.Settings.Default.FreeFootieConnectionString;
                using (FreeFootieDataContext myData = new FreeFootieDataContext(connectionString))
                {
                    using (TransactionScope myScope = new TransactionScope())
                    {
                        game newGame = new game();
                        var newID = (from c in myData.games
                                     select c.id).Max();
                        newGame.id = newID + 1;

                        newGame.awayTeamID = game.away;
                        newGame.duration = game.duration;
                        newGame.homeTeamID = game.home;
                        newGame.locationID = game.location;
                        string[] date_duration = game.date.Replace("<", string.Empty).Replace(">", string.Empty).Replace("h", string.Empty).Split('~');
                        if (date_duration.Count() > 0)
                        {
                            newGame.startTime = Convert.ToDateTime(date_duration[0]);
                        }
                        if (date_duration.Count() > 1)
                        {
                            newGame.duration = Convert.ToInt32(date_duration[1]);
                        }
                        newGame.state = game.state;
                        newGame.homeTeamScore = game.homeTeamScore;
                        newGame.awayTeamScore = game.awayTeamScore;

                        myData.games.InsertOnSubmit(newGame);

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