public ActionResult Cadastro(int?id) { var model = new TipoEspaco(); if (id != null && id > 0) { model = db.TipoEspaco.Find(id); } return(View(model)); }
public ActionResult Cadastro(TipoEspaco tipoEspaco) { if (ModelState.IsValid) { if (tipoEspaco.Id > 0) { db.Entry(tipoEspaco).State = EntityState.Modified; } else { db.TipoEspaco.Add(tipoEspaco); } db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tipoEspaco)); }