コード例 #1
0
        public ActionResult Agregar(Estadistica estadistica, int id)
        {
            Evento evento = db.Eventos.Find(id);
            estadistica.Evento = evento;
            try
            {
                if (ModelState.IsValid)
                {
                    db.Estadisticas.Add(estadistica);
                    db.SaveChanges();

                    evento = estadistica.Evento;
                    evento.Estadistica = estadistica;
                    db.Entry(evento).State = EntityState.Modified;
                    db.SaveChanges();

                }
                return RedirectToAction("Index", "Evento", null);
            }
            catch (Exception ex)
            {
                TempData["Error"] = ex.Message;
                return View("Error");
            }
        }
コード例 #2
0
 public ActionResult Agregar(int id)
 {
     Estadistica estadistica = new Estadistica();
     Evento evento = db.Eventos.Find(id);
     estadistica.Evento = evento;
     return View(estadistica);
 }