public ActionResult Edit([Bind(Include = "Id,nombre,descripcion,fechaBaja,estadoHab")] Especy especy) { if (ModelState.IsValid) { try { if (especy.estadoHab == false) { if (especy.fechaBaja == null) { especy.fechaBaja = DateTime.Now; } } else { especy.fechaBaja = null; } db.Entry(especy).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } catch (Exception ex) { return(View("ErrorCreateDup", new HandleErrorInfo(ex, "Especies", "Edit"))); } } return(View(especy)); }
public ActionResult DeleteConfirmed(int id) { try { Especy especy = db.Especies.Find(id); db.Especies.Remove(especy); db.SaveChanges(); return(RedirectToAction("Index")); } catch (Exception ex) { return(View("ErrorDeleteRef", new HandleErrorInfo(ex, "Especies", "Delete"))); } }
// GET: Especies/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Especy especy = db.Especies.Find(id); if (especy == null) { return(HttpNotFound()); } return(View(especy)); }