public int CreateFamousPerson(CreateFamousPersonCommand cmd) { var person = cmd.ToPerson(); _context.Add(person); _context.SaveChanges(); return(person.Id); }
public IActionResult Create(CreateFamousPersonCommand command) { try { if (ModelState.IsValid) { var id = _service.CreateFamousPerson(command); return(RedirectToAction(nameof(View), new { id = id })); } } catch (Exception) { ModelState.AddModelError( string.Empty, "An error occured saving the recipe" ); } return(View(command)); }