public ActionResult Agregar(usuariomodels model) { if (ModelState.IsValid) { usuario U = new usuario { id = model.id, nombre = model.nombre, username = model.username, password = model.password, apellido = model.apellido, fechanac = model.fechanac, email = model.email, }; db.usuarios.InsertOnSubmit(U); try { db.SubmitChanges(); } catch (Exception e) { Console.WriteLine(e); // Make some adjustments. // ... // Try again. //db.SubmitChanges(); return View(); } return RedirectToAction("Index"); } return View(); }
/* -------------------------------------------------------------------------------------- */ public ActionResult Verpuntosportorneo(int idtorneo) { var iduser = (int)Session["id"]; var total = new usuariomodels().vermispuntosportorneo(idtorneo, iduser); return View(); }
/* -------------------------------------------------------------------------------------- */ public ActionResult Ver(int id) { var auxusuario = new usuariomodels().verusuario(id).First(); ViewBag.id = auxusuario.id; ViewBag.username = auxusuario.username; ViewBag.password = auxusuario.password; ViewBag.nombre = auxusuario.nombre; ViewBag.appellido = auxusuario.apellido; ViewBag.fechanac = auxusuario.fechanac; ViewBag.email = auxusuario.email; return View(); }
/* -------------------------------------------------------------------------------------- */ public bool SaveTorneo(usuariomodels model) { if (ModelState.IsValid) { try { usuario T = new usuario(); T = db.usuarios.Single(q => q.id == model.id); T.id =model.id; T.nombre =model.nombre; T.username =model.username; T.password =model.password; T.apellido =model.apellido; T.fechanac =model.fechanac; T.email = model.email; db.SubmitChanges(); return true; } catch { return false; } } return false; }
/* -------------------------------------------------------------------------------------- */ public ActionResult Index() { var lusuarios = new usuariomodels().listausuarios(); return View(lusuarios); }
/* -------------------------------------------------------------------------------------- */ public ActionResult Eliminar(int id) { var aux = new usuariomodels().verusuario(id).First(); usuario T = new usuario { id = aux.id, nombre = aux.nombre, username = aux.username, password = aux.password, apellido = aux.apellido, fechanac = aux.fechanac, email = aux.email, }; db.usuarios.Attach(T); db.usuarios.DeleteOnSubmit(T); db.SubmitChanges(); try { } catch (Exception e) { Console.WriteLine(e); // Make some adjustments. // ... // Try again. //db.SubmitChanges(); } return RedirectToAction("Index"); }
public ActionResult Editar(int idu, usuariomodels model) { try { if (this.SaveTorneo(model)) { return RedirectToAction("Index"); } else { return View(); } } catch (Exception e) { return View(e.Message); } }
/* -------------------------------------------------------------------------------------- */ public ActionResult Editar(int idu) { MvcApplication6.Models.usuario Us = new MvcApplication6.Models.usuario(); try { Us = db.usuarios.Single(q => q.id == idu); usuariomodels tmodel = new usuariomodels(); tmodel.id = Us.id; tmodel.nombre = Us.nombre; tmodel.username = Us.username; tmodel.password = Us.password; tmodel.apellido = Us.apellido; tmodel.fechanac = Us.fechanac; tmodel.email = Us.email; return View(tmodel); } catch { return RedirectToAction("Index"); } }