public ActionResult Create(VilleViewModel villeVm) { if (ModelState.IsValid) { try { this._repository.Create(villeVm.Map <Ville>()); this._repository.Commit(); return(RedirectToAction(nameof(this.Index))); } catch (Exception ex) { ModelState.AddModelError(string.Empty, ex.Message); } } return(View(villeVm)); }
public ActionResult Edit(VilleViewModel villeVm) { if (!ModelState.IsValid) { return(View(villeVm)); } try { Ville ville = this._repository.Get(villeVm.Id); villeVm.Map(ville); this._repository.Commit(); return(RedirectToAction(nameof(this.Index))); } catch (Exception ex) { ModelState.AddModelError(string.Empty, ex.Message); } return(View(villeVm)); }