示例#1
0
        public int CreateFamousPerson(CreateFamousPersonCommand cmd)
        {
            var person = cmd.ToPerson();

            _context.Add(person);
            _context.SaveChanges();
            return(person.Id);
        }
示例#2
0
 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));
 }