Exemple #1
0
        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));
        }
Exemple #2
0
 public IActionResult Edit(int id, [FromBody] UpdatePersonCommand command)
 {
     _service.UpdatePerson(command);
     return(Ok());
 }