public bool CreateRushingStats(NFLPlayerStats_RushingCreate model) { var entity = new NFLPlayerStats_Rushing() { PlayerId = model.PlayerId, Attempts = model.Attempts, Yards = model.Yards, Touchdowns = model.Touchdowns }; using (var ctx = new ApplicationDbContext()) { ctx.NFLPlayer_Rushing.Add(entity); return(ctx.SaveChanges() == 1); } }
public ActionResult Create(NFLPlayerStats_RushingCreate model) { if (!ModelState.IsValid) { return(View(model)); } var service = CreateRushingService(); if (service.CreateRushingStats(model)) { TempData["SaveResult"] = "Rushing stats added"; return(RedirectToAction("Index")); } ; ModelState.AddModelError("", "Rushing stats could not be added."); return(View(model)); }