public ActionResult Create(FormCollection collection) { if (ModelState.IsValid) { var primero = Convert.ToInt32(collection["PrimerNumero"].ToString()); var segundo = Convert.ToInt32(collection["SegundoNumero"].ToString()); var tercero = Convert.ToInt32(collection["TercerNumero"].ToString()); if (primero != segundo && segundo != tercero && primero != tercero) { var data = collection["Sorteos"].ToString(); var sorteo = db.Sorteos.Find(Convert.ToInt32(collection["Sorteos"].ToString())); var objGanadores = new Ganadores { PrimerNumero = Convert.ToInt32(collection["PrimerNumero"].ToString()), SegundoNumero = Convert.ToInt32(collection["SegundoNumero"].ToString()), TercerNumero = Convert.ToInt32(collection["TercerNumero"].ToString()), Sorteos = sorteo }; db.Ganadores.Add(objGanadores); db.SaveChanges(); notificarGanadores(sorteo.Id, objGanadores.PrimerNumero, 1); notificarGanadores(sorteo.Id, objGanadores.SegundoNumero, 2); notificarGanadores(sorteo.Id, objGanadores.TercerNumero, 3); Ganadores.updateSorteo(db, sorteo.Id); TempData["Success"] = "Ganadores registrados correctamente."; return(RedirectToAction("Index")); } TempData["Error"] = "Los números ganadores no pueden ser iguales"; return(RedirectToAction("Index")); } return(RedirectToAction("Index")); }
public ActionResult DeleteConfirmed(int id) { Ganadores ganadores = db.Ganadores.Find(id); db.Ganadores.Remove(ganadores); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "Id,PrimerNumero,SegundoNumero,TercerNumero")] Ganadores ganadores) { if (ModelState.IsValid) { db.Entry(ganadores).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(ganadores)); }
// GET: Ganadores public ActionResult Index() { var manager = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(new ApplicationDbContext())); var currentUser = manager.FindById(User.Identity.GetUserId()); if (!currentUser.Is_Admin) { return(Redirect("Apuestas")); } ViewBag.Ganadores = Ganadores.getGanadores(db); return(View()); }
// GET: Ganadores/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Ganadores ganadores = db.Ganadores.Find(id); if (ganadores == null) { return(HttpNotFound()); } return(View(ganadores)); }