Example #1
0
        public ActionResult Agregar(equipomodels model)
        {
            if (ModelState.IsValid)
            {
                equipo E = new equipo
                {
                    nombre = model.nombre
                };

                db.equipos.InsertOnSubmit(E);
                try
                {
                    db.SubmitChanges();
                }
                catch
                {
                    TempData["ERROR"] = "No se pudo agregar el equipo, por favor intente nuevamente.";
                    return View();
                }
               // HttpRuntime.Cache.Remove("EQUIPOS");
                TempData["MENSAJE"] = "Se agrego correctamente el equipo.";
                return RedirectToAction("Index");
            }
            TempData["ERROR"] = "Error en el alta del equipo.";
            return View();
        }
Example #2
0
 /* --------------------------------------------------------------------------------------  */
 public ActionResult Editar(int id)
 {
     equipo T = new equipo();
     try
     {
         T = db.equipos.Single(q => q.id == id);
         equipomodels emodel = new equipomodels();
         emodel.id       = T.id;
         emodel.nombre   = T.nombre;
         return View(emodel);
     }
     catch
     {
         TempData["ERROR"] = "No se pudo editar el equipo, por favor intente nuevamente.";
         return RedirectToAction("Index");
     }
 }
Example #3
0
 partial void Deleteequipo(equipo instance);
Example #4
0
 partial void Updateequipo(equipo instance);
Example #5
0
 partial void Insertequipo(equipo instance);
Example #6
0
 /* --------------------------------------------------------------------------------------  */
 /* --------------------------------------------------------------------------------------  */
 public bool SaveEquipo(equipomodels model)
 {
     if (ModelState.IsValid)
     {
         try
         {
             equipo T = new equipo();
             T = db.equipos.Single(q => q.id == model.id);
             T.nombre = model.nombre;
             db.SubmitChanges();
             return true;
         }
         catch
         {
             return false;
         }
     }
     return false;
 }
Example #7
0
 /* --------------------------------------------------------------------------------------  */
 public ActionResult Eliminar(int id)
 {
     var equipo = new equipomodels().verequipo(id).First();
     MvcApplication6.Models.equipo T = new equipo
     {
         id      = equipo.id,
         nombre  = equipo.nombre
     };
     try
     {
         db.equipos.Attach(T);
         db.equipos.DeleteOnSubmit(T);
         db.SubmitChanges();
         TempData["MENSAJE"] = "Se elimino correctamente el El equipo.";
     }
     catch
     {
         TempData["ERROR"] = "No se pudo eliminar el Equipo, por favor intente nuevamente.";
     }
     return RedirectToAction("Index");
 }