public ActionResult Edit([Bind(Include = "Id,Nome,SobreNome")] Pessoa pessoa)
 {
     if (ModelState.IsValid)
     {
         db.Update(pessoa);
         return(RedirectToAction("Index"));
     }
     return(View(pessoa));
 }
Beispiel #2
0
        public async Task <IActionResult> Edit(Pessoa model, long Id)
        {
            try
            {
                if (model.PessoaID != Id)
                {
                    return(NotFound());
                }
                if (ModelState.IsValid)
                {
                    await _Repository.Update(model);

                    return(RedirectToAction(nameof(Index)));
                }
            }
            catch (Exception e)
            {
                ModelState.Clear();
                ModelState.AddModelError("", e.Message);
            }

            return(View(model));
        }