public IActionResult Edit(UpdatePersonCommand command) { try { if (ModelState.IsValid) { _person.UpdatePerson(command); return(RedirectToAction(nameof(View), new { id = command.PersonId })); } } catch (Exception) { // Add a model-level error by using an empty string key ModelState.AddModelError( string.Empty, "An error occured updating person" ); } //If we got to here, something went wrong return(View(command)); }
public IActionResult Edit(int id, [FromBody] UpdatePersonCommand command) { _service.UpdatePerson(command); return(Ok()); }