public ActionResult Agregar() { if (Request.Cookies["RolCookie"] == null) { return(RedirectToAction("Login", "Registro")); } else { var idC = Request.Cookies["RolCookie"].Value; var c = new HttpCookie("RolCookie"); c.Value = idC; c.Expires = DateTime.Now.AddMinutes(15); Response.Cookies.Add(c); } var JugadorView = new JugadoresSalonesView(); JugadorView.Jugadores = new List <tbl_Jugadores>(); var id = Session["IdSalon"]; var listC = db.tbl_Salones.ToList().Where(x => x.IdAdministrador == Convert.ToInt32(Request.Cookies["RolCookie"].Value)); ViewBag.IdSalon = new SelectList(listC, "Id", "Id", id); Session["JugadorSalonView"] = JugadorView; return(View(JugadorView)); }
// GET: Salones/Details/5 public ActionResult Details(int?id) { if (Request.Cookies["RolCookie"] == null) { return(RedirectToAction("Login", "Registro")); } else { var idC = Request.Cookies["RolCookie"].Value; var c = new HttpCookie("RolCookie"); c.Value = idC; c.Expires = DateTime.Now.AddMinutes(15); Response.Cookies.Add(c); } if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var SalonJView = new JugadoresSalonesView(); SalonJView.Salones = new tbl_Salones(); SalonJView.Salones = db.tbl_Salones.Find(id); var Jugadores = db.tbl_JugadoresSalones.SqlQuery("sp_ConsultaJugadoresxSalon @IdSalon", new SqlParameter("@IdSalon", id)).ToList(); SalonJView.CantJugadores = Jugadores.Select(x => x.IdJugador).Count(); return(View(SalonJView)); }
public ActionResult Agregar(JugadoresSalonesView JugadorRView) { if (Request.Cookies["RolCookie"] == null) { return(RedirectToAction("Login", "Registro")); } else { var idC = Request.Cookies["RolCookie"].Value; var c = new HttpCookie("RolCookie"); c.Value = idC; c.Expires = DateTime.Now.AddMinutes(15); Response.Cookies.Add(c); } var JugadorSalonView = Session["JugadorSalonView"] as JugadoresSalonesView; var IdSalon = Request["IdSalon"]; if (IdSalon == "") { ViewBag.Error = "Debe ingresar un id de salon"; return(View(JugadorSalonView)); } var Salones = db.tbl_Salones.SqlQuery("sp_ConsultarSalon @ID", new SqlParameter("@ID", IdSalon)).ToList(); if (Salones.Count() == 0) { ViewBag.Error = "El id de salon no existe"; return(View(JugadorSalonView)); } if (JugadorSalonView.Jugadores.Count == 0) { ViewBag.Error = "Debe ingresar Jugadores"; return(View(JugadorSalonView)); } foreach (var item in JugadorSalonView.Jugadores) { var Respuesta = db.tbl_JugadoresSalones.SqlQuery("sp_InsertarJugadorSalon @IdJ,@IdS", new SqlParameter("@IdJ", item.Id), new SqlParameter("@IdS", IdSalon)).ToList(); } var listC = db.tbl_Salones.ToList().Where(x => x.IdAdministrador == Convert.ToInt32(Request.Cookies["RolCookie"].Value)); ViewBag.IdSalon = new SelectList(listC, "Id", "Id"); return(View(JugadorRView)); }
public ActionResult EditarSalon(JugadoresSalonesView JugadorRView) { if (Request.Cookies["RolCookie"] == null) { return(RedirectToAction("Login", "Registro")); } else { var idC = Request.Cookies["RolCookie"].Value; var c = new HttpCookie("RolCookie"); c.Value = idC; c.Expires = DateTime.Now.AddMinutes(15); Response.Cookies.Add(c); } var JugadorSalonView = Session["JugadorSalonView"] as JugadoresSalonesView; var IdSalon = Session["IdSalon"]; if (IdSalon == "") { ViewBag.Error = "Debe ingresar un id de salon"; return(View(JugadorSalonView)); } var Salones = db.tbl_Salones.SqlQuery("sp_ConsultarSalon @ID", new SqlParameter("@ID", IdSalon)).ToList(); if (Salones.Count() == 0) { ViewBag.Error = "El id de salon no existe"; return(View(JugadorSalonView)); } if (JugadorSalonView.Jugadores.Count == 0) { ViewBag.Error = "Debe ingresar Jugadores"; return(View(JugadorSalonView)); } var Lista = db.tbl_JugadoresSalones.SqlQuery("sp_EliminarJugadorSalon @IdS", new SqlParameter("@IdS", IdSalon)).ToList(); foreach (var item in JugadorSalonView.Jugadores) { var Respuesta = db.tbl_JugadoresSalones.SqlQuery("sp_InsertarJugadorSalon @IdP,@IdS", new SqlParameter("@IdP", item.Id), new SqlParameter("@IdS", IdSalon)).ToList(); } return(RedirectToAction("Index")); }
public ActionResult EditarSalon(int?Id) { if (Request.Cookies["RolCookie"] == null) { return(RedirectToAction("Login", "Registro")); } else { var idC = Request.Cookies["RolCookie"].Value; var c = new HttpCookie("RolCookie"); c.Value = idC; c.Expires = DateTime.Now.AddMinutes(15); Response.Cookies.Add(c); } var JugadorRView = new JugadoresSalonesView(); JugadorRView.Jugadores = new List <tbl_Jugadores>(); JugadorRView.Jugadores = db.tbl_Jugadores.SqlQuery("sp_ConsultaJugadorSalon @IdS", new SqlParameter("@IdS", Id)).ToList(); Session["IdSalon"] = Id; Session["JugadorSalonView"] = JugadorRView; return(View(JugadorRView)); }