public bool CreateSpotter(SpotterCreate model) { var entity = new Spotter() { FirstName = model.FirstName, LastName = model.LastName }; using (var ctx = new ApplicationDbContext()) { ctx.Spotters.Add(entity); return(ctx.SaveChanges() == 1); } }
public ActionResult Create(SpotterCreate model) { if (!ModelState.IsValid) { return(View(model)); } var service = CreateSpotterService(); if (service.CreateSpotter(model)) { TempData["SaveResult"] = "The potter was added!"; return(RedirectToAction("Index")); } ; ModelState.AddModelError("", "The spotter could not be added."); return(View(model)); }