// 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"); } }
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"); } }
private void detach_games(game entity) { this.SendPropertyChanging(); entity.location = null; }
private void attach_games(game entity) { this.SendPropertyChanging(); entity.location = this; }
partial void Deletegame(game instance);
partial void Updategame(game instance);
partial void Insertgame(game instance);