예제 #1
0
        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));
        }
예제 #2
0
        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));
        }