public IActionResult Save([FromForm] PersonViewModel obj) { if (!ModelState.IsValid) { return(View("Edit", obj)); } var person = PersonViewModel.Convert(obj); repository.Persons.Save(person); return(Redirect("/Person/Index")); }
public IActionResult Edit(int id) { var person = repository.Persons.ById(id); var obj = PersonViewModel.Convert(person); if (obj != null) { return(View("Edit", obj)); } else { return(NotFound()); } }