예제 #1
0
        public ActionResult Agregar(torneomodels model)
        {
            if (ModelState.IsValid)
            {
                torneo T = new torneo
                {
                    nombre = model.nombre
                };

                db.torneos.InsertOnSubmit(T);
                try
                {
                    db.SubmitChanges();
                }
                catch
                {
                    TempData["ERROR"] = "No se pudo agregar el torneo, por favor intente nuevamente.";
                    return View();
                }
                TempData["MENSAJE"] = "Se agrego correctamente el torneo.";
                return RedirectToAction("Index");
            }
            TempData["ERROR"] = "Error en el alta del torneo.";
            return View();
        }
예제 #2
0
 /* --------------------------------------------------------------------------------------  */
 public ActionResult Editar(int id)
 {
     torneo T = new torneo();
     try
     {
         T = db.torneos.Single(q => q.id == id);
         torneomodels tmodel = new torneomodels();
         tmodel.id       = T.id;
         tmodel.nombre   = T.nombre;
         return View(tmodel);
     }
     catch
     {
         TempData["ERROR"] = "No se pudo editar el torneo, por favor intente nuevamente.";
         return RedirectToAction("Index");
     }
 }
예제 #3
0
 /* --------------------------------------------------------------------------------------  */
 public ActionResult Eliminar(int id)
 {
     var torneo1 = new torneomodels().vertorneo(id).First();
     torneo T = new torneo
     {
         id      =torneo1.id,
         nombre  =torneo1.nombre
     };
     try
     {
         db.torneos.Attach(T);
         db.torneos.DeleteOnSubmit(T);
         db.SubmitChanges();
         TempData["MENSAJE"] = "Se elimino correctamente el torneo.";
     }
     catch
     {
         TempData["ERROR"] = "No se pudo eliminar el torneo, por favor intente nuevamente.";
     }
     return RedirectToAction("Index");
 }
예제 #4
0
 /* --------------------------------------------------------------------------------------  */
 public bool SaveTorneo(torneomodels model)
 {
     if (ModelState.IsValid)
     {
         try
         {
             torneo T = new torneo();
             T = db.torneos.Single(q => q.id == model.id);
             T.nombre = model.nombre;
             db.SubmitChanges();
             return true;
         }
         catch
         {
             return false;
         }
     }
     return false;
 }
예제 #5
0
 partial void Deletetorneo(torneo instance);
예제 #6
0
 partial void Updatetorneo(torneo instance);
예제 #7
0
 partial void Inserttorneo(torneo instance);