public ActionResult Delete(Centro model) { try { model = contexto.Centros.Find(model.Id); contexto.Centros.Remove(model); contexto.SaveChanges(); return RedirectToAction("Index"); } catch { return View(); } }
public ActionResult Create(Centro model) { try { if (ModelState.IsValid) { contexto.Centros.Add(model); contexto.SaveChanges(); return RedirectToAction("Index"); } return View(model); } catch { return View(); } }
public ActionResult Edit(Centro model) { try { if (ModelState.IsValid) { contexto.Entry(model).State = System.Data.EntityState.Modified; contexto.Entry(model.Endereco).State = System.Data.EntityState.Modified; contexto.SaveChanges(); return RedirectToAction("Index"); } return View(); } catch { return View(); } }
public ActionResult Create() { Centro model = new Centro(); model.Endereco = new Endereco(); return View(model); }