public bool CreateOffenseStats(NFLTeamStats_OffenseCreate model) { var entity = new NFLTeamStats_Offense() { TeamId = model.TeamId, Team = model.Team, GamesPlayed = model.GamesPlayed, PointsForced = model.PointsForced }; using (var ctx = new ApplicationDbContext()) { ctx.NFLTeam_Offense.Add(entity); return(ctx.SaveChanges() == 1); } }
public ActionResult Create(NFLTeamStats_OffenseCreate model) { if (!ModelState.IsValid) { return(View(model)); } var service = CreateOffenseStatsService(); if (service.CreateOffenseStats(model)) { TempData["SaveResult"] = "Offense stats were added."; return(RedirectToAction("Index")); } ModelState.AddModelError("", "Offense stats could not be added."); return(View(model)); }