mtsys

Untitled

Jan 9th, 2018
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.44 KB | None | 0 0
  1. public ActionResult Cadastro(Pessoa model)
  2. {
  3.     using (var db = new Conexao())
  4.     {
  5.         if (model.PessoaID == 0)
  6.         {
  7.             db.Pessoa.Add(model);
  8.         }
  9.         else
  10.         {
  11.             var registro = db.Pessoa.Find(model.PessoaID);
  12.             UpdateModel(registro);
  13.         }
  14.  
  15.         db.SaveChanges();
  16.  
  17.         return RedirectToAction("Cadastro", controller, new { id = model.PessoaID });
  18.     }            
  19. }
Advertisement
Add Comment
Please, Sign In to add comment