Ejemplo n.º 1
0
 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));
 }
Ejemplo n.º 2
0
 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")));
     }
 }
Ejemplo n.º 3
0
        // 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));
        }