public ActionResult Create(BeatTheGoalieCreateViewModel viewModel) { if (ModelState.IsValid) { viewModel.BeatTheGoalie.Descripcion = viewModel.BeatTheGoalie.Respuesta1 + " | " + viewModel.BeatTheGoalie.Respuesta2 + " | " + viewModel.BeatTheGoalie.Respuesta3 + " | " + viewModel.BeatTheGoalie.Respuesta4; if (!string.IsNullOrEmpty(viewModel.BeatTheGoalie.Enunciado)) { viewModel.BeatTheGoalie.Descripcion = viewModel.BeatTheGoalie.Enunciado; } db.BeatTheGoalies.Add(viewModel.BeatTheGoalie); db.SaveChanges(); if (viewModel.AudioFile != null) { viewModel.BeatTheGoalie.FicheroAudio = viewModel.BeatTheGoalie.Id + ".mp3"; string nameAndLocation = "~/media/upload/BeatTheGoalie/" + viewModel.BeatTheGoalie.FicheroAudio; viewModel.AudioFile.SaveAs(Server.MapPath(nameAndLocation)); db.Entry(viewModel.BeatTheGoalie).State = EntityState.Modified; db.SaveChanges(); } return(RedirectToAction("Create", "BeatTheGoalies", new { id = viewModel.BeatTheGoalie.JuegoOnlineId })); } viewModel.Inicializar(viewModel.BeatTheGoalie.JuegoOnlineId); return(View(viewModel)); }
// GET: Admin/BeatTheGoalies/Create public ActionResult Create(int id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } JuegoOnline JuegoOnline = db.JuegoOnlines.SingleOrDefault(bl => bl.JuegoOnlineId == id); if (JuegoOnline == null) { return(HttpNotFound()); } BeatTheGoalieCreateViewModel viewModel = new BeatTheGoalieCreateViewModel(); viewModel.Inicializar(id); viewModel.BeatTheGoalie = new BeatTheGoalie(); viewModel.BeatTheGoalie.TipoJuegoOnlineId = (int)TiposDeJuegosOnlineId.BeatTheGoalie; viewModel.BeatTheGoalie.JuegoOnlineId = id; viewModel.BeatTheGoalie.SubTemaId = JuegoOnline.SubTemaId; return(View(viewModel)); }