public bool CreatePlayer(NFLPlayerInfoCreate model) { var entity = new NFLPlayerInfo() { FirstName = model.FirstName, LastName = model.LastName, Position = model.Position, Team = model.Team, }; using (var ctx = new ApplicationDbContext()) { ctx.PlayerInfo.Add(entity); return(ctx.SaveChanges() == 1); } }
public ActionResult Create(NFLPlayerInfoCreate model) { if (!ModelState.IsValid) { return(View(model)); } var service = CreatePlayerService(); if (service.CreatePlayer(model)) { TempData["SaveResult"] = "Player was created."; return(RedirectToAction("Index")); } ; ModelState.AddModelError("", "Player could not be created."); return(View(model)); }