public ActionResult SaveFcDeHoekGame(FcDeHoekGameModel model) { using (var context = new FcDeHoekContext()) { var statsToRemove = context.PersonStatistics.Where(ps => ps.IdGame == model.IdGame).ToList(); if (statsToRemove.Any()) { context.PersonStatistics.RemoveRange(statsToRemove); context.SaveChanges(); } foreach (var player in model.PlayersInGame) { if (player.IdPlayer != -1) { var stat = new PersonStats { IdGame = model.IdGame, IdPerson = player.IdPlayer, Assists = player.AssistsGiven, Goals = player.GoalsScored, Played = true }; context.PersonStatistics.AddOrUpdate(stat); context.SaveChanges(); } } return(FcDeHoekGameDetail(model.IdGame)); } }
public ActionResult Save(PersonModel model) { using (var context = new FcDeHoekContext()) { Person person; if (model.IdPerson == 0) { person = new Person(); } else { person = PersonQueries.GetById(context, model.IdPerson); } person.BirthDate = model.BirthDate; person.FirstName = model.FirstName; person.IsPlayer = model.IsPlayer; person.IsStaff = model.IsStaff; person.Name = model.Name; person.PerkezNumber = model.PerkezNumber; person.PhoneNumber = model.PhoneNumber; person.PicturePath = model.Picture; person.Function = model.Function; context.Persons.AddOrUpdate(person); context.SaveChanges(); } return(RedirectToAction("Index")); }
public ActionResult Save(ScoreModel model) { using (var context = new FcDeHoekContext()) { foreach (var gameModel in model.Games) { var game = GameQueries.GetById(context, gameModel.IdGame); game.GoalsHomeTeam = gameModel.GoalsHomeTeam; game.GoalsAwayTeam = gameModel.GoalsAwayTeam; context.Games.AddOrUpdate(game); context.SaveChanges(); } return(RedirectToAction("EditScores", new { fixtureDate = model.FixtureDate })); } }
public ActionResult Save(HistoricStatsModel model) { using (var context = new FcDeHoekContext()) { var historicStat = new HistoricStats(); historicStat.IdHistoricStats = model.IdHistoricStats; historicStat.IdSeason = model.IdSeason; historicStat.IdPerson = model.IdPlayer; historicStat.Goals = model.Goals; historicStat.Assists = model.Assists; historicStat.Penalties = model.Penalties; context.HistoricStatses.AddOrUpdate(historicStat); context.SaveChanges(); return(RedirectToAction("Index")); } }
public ActionResult Save(GameManagerModel model) { using (var context = new FcDeHoekContext()) { var game = GameQueries.GetById(context, model.Games[0].IdGame); if (game == null) { game = new Game(); } foreach (var gameModel in model.Games) { game.GoalsAwayTeam = gameModel.GoalsAwayTeam; game.GoalsHomeTeam = gameModel.GoalsHomeTeam; game.Forfait = gameModel.Forfait; game.IdCompetition = gameModel.IdCompetition; game.IdAwayTeam = gameModel.IdAwayTeam; game.IdHomeTeam = gameModel.IdHomeTeam; game.IdPostPonedGame = gameModel.IdPostPonedGame; game.IdSeason = SeasonQueries.GetSeasonByDate(context, gameModel.MatchDay)?.IdSeason ?? SeasonQueries.GetCurrentSeason(context).IdSeason; game.MatchDate = gameModel.MatchDay; game.NotPlayed = gameModel.IsPostPoned; context.Games.AddOrUpdate(game); context.SaveChanges(); } if (model.AddAnother) { if (model.Games.Count > 1) { return(RedirectToAction("AddMultipleGames", "GameManager", new { idGame = 0 })); } else { return(RedirectToAction("EditGame", "GameManager", new { idGame = 0 })); } } return(RedirectToAction("Index", "GameManager")); } }
public ActionResult SaveUser(UserModel model) { using (var context = new FcDeHoekContext()) { var user = UserQueries.GetById(context, model.IdUser); if (user == null) { user = new User(); } user.UserName = model.UserName; user.IsAdmin = model.IsAdmin; user.Obsolete = model.Obsolete; context.Users.AddOrUpdate(user); context.SaveChanges(); } return(RedirectToAction("Index", "User")); }
public ActionResult Save(SeasonModel model) { using (var context = new FcDeHoekContext()) { Season season; if (model.IdSeason == 0) { season = new Season(); } else { season = SeasonQueries.GetById(context, model.IdSeason); } season.SeasonStartYear = model.StartYear; season.SeasonEndYear = model.EndYear; season.Division = model.Division; context.Seasons.AddOrUpdate(season); context.SaveChanges(); } return(RedirectToAction("Index")); }