public ActionResult DeleteConfirmed(int id) { cao cao = db.Caes.Find(id); db.Caes.Remove(cao); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "ID_cao,Nome,ID_raca")] cao cao) { if (ModelState.IsValid) { db.Entry(cao).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(cao)); }
public ActionResult Create([Bind(Include = "ID_cao,Nome,ID_raca")] cao cao) { if (ModelState.IsValid) { db.Caes.Add(cao); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(cao)); }
// GET: Cao/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } cao cao = db.Caes.Find(id); if (cao == null) { return(HttpNotFound()); } else { cao.Nome_Raca = db.Racas.Where(x => x.ID_raca == cao.ID_raca).ToList().FirstOrDefault().Nome; } return(View(cao)); }