public ActionResult Create(PersonViewModel personViewModel) { try { if (!ModelState.IsValid) { ReplaceMessege("PersonCitizenship","PersonCitizenship", Resource.PersonCitizenship); return View(personViewModel); } var result = _controleHelper.CreateEntity<Person, PersonViewModel>(personViewModel); if (result.Error.Any()) { ModelState.AddModelError(string.Empty, result.Error.First().ErrorMessage); return View(personViewModel); } return RedirectToAction("Details", new { id = result.Entity.Id }); } catch (Exception ex) { ModelState.AddModelError(string.Empty, ex); return View(personViewModel); } }
public ActionResult Edit(long id, PersonViewModel clientViewModel) { try { if (!ModelState.IsValid) { ReplaceMessege("PersonCitizenship", "PersonCitizenship", Resource.PersonCitizenship); return View(clientViewModel); } var result = _controleHelper.UpdateEntity<Person, PersonViewModel>(clientViewModel, l => l.Id == id); if (result.Error.Any()) { return View(clientViewModel); } return RedirectToAction("Details", new { id = result.Entity.Id }); } catch (Exception ex) { ModelState.AddModelError(string.Empty, ex.Message); return View(clientViewModel); } }