public bool UpdateTeamSeasonBet(TeamSeasonBetEdit model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx .TeamSeasonBets .Single(e => e.BaseId == model.BaseId && e.OwnerId == _userId); entity.Sport = model.Sport; entity.League = model.League; entity.Team = model.Team; entity.TeamPick = model.TeamPick; return(ctx.SaveChanges() == 1); } }
public ActionResult Edit(int id) { var service = CreateTeamSeasonBetService(); var detail = service.GetTeamSeasonBetById(id); var model = new TeamSeasonBetEdit { BaseId = detail.BaseId, Sport = detail.Sport, League = detail.League, Team = detail.Team, TeamPick = detail.TeamPick, Odds = detail.Odds, AmountBet = detail.AmountBet }; return(View(model)); }
public ActionResult Edit(int id, TeamSeasonBetEdit model) { if (!ModelState.IsValid) { return(View(model)); } if (model.BaseId != id) { ModelState.AddModelError("", "Team ID Mismatch"); return(View(model)); } var service = CreateTeamSeasonBetService(); if (service.UpdateTeamSeasonBet(model)) { TempData["SaveResult"] = "Your bet was updated"; return(RedirectToAction("Index")); } ModelState.AddModelError("", "Your bet could not be updated"); return(View(model)); }
public ActionResult Edit(int id) { var service = CreatePlayerGameBetService(); var detail = service.GetPlayerGameBetById(id); if (detail.GetType() == typeof(PlayerGameBetDetail)) { var some = (PlayerGameBetDetail)detail; var model = new PlayerGameBetEdit { BaseId = some.BaseId, Sport = some.Sport, League = some.League, PlayerName = some.PlayerName, PlayerTeam = some.PlayerTeam, PlayerPick = some.PlayerPick, Odds = some.Odds, AmountBet = some.AmountBet, }; return(View(model)); } else if (detail.GetType() == typeof(TeamSeasonBetDetail)) { var some = (TeamSeasonBetDetail)detail; var model = new TeamSeasonBetEdit { BaseId = some.BaseId, Sport = some.Sport, League = some.League, Team = some.Team, TeamPick = some.TeamPick, Odds = some.Odds, AmountBet = some.AmountBet }; return(View(model)); } else if (detail.GetType() == typeof(SingleGameBetDetail)) { var some = (SingleGameBetDetail)detail; var model = new SingleGameBetEdit { BaseId = some.BaseId, Sport = some.Sport, League = some.League, HomeTeam = some.HomeTeam, AwayTeam = some.AwayTeam, GamePick = some.GamePick, Odds = some.Odds, AmountBet = some.AmountBet }; return(View(model)); } else { return (null); } }