public bool CreatePassingStats(NFLPlayerStats_PassingCreate model) { var entity = new NFLPlayerStats_Passing() { PlayerId = model.PlayerId, Player = model.Player, Completions = model.Completions, Attempts = model.Attempts, Yards = model.Yards }; using (var ctx = new ApplicationDbContext()) { ctx.NFLPlayer_Passing.Add(entity); return(ctx.SaveChanges() == 1); } }
public ActionResult Create(NFLPlayerStats_PassingCreate model) { if (!ModelState.IsValid) { return(View(model)); } var service = CreatePassingStatsService(); if (service.CreatePassingStats(model)) { TempData["SaveResult"] = "Passing Stat was created."; return(RedirectToAction("Index")); } ; ModelState.AddModelError("", "Passing stat could not be created."); return(View(model)); }