// GET: Admin/Vocabularios/Create public ActionResult Create( ) { VocabularioCreateViewModel viewModel = new VocabularioCreateViewModel(); viewModel.InicializarDesplegables(); return(View(viewModel)); }
public ActionResult Create(VocabularioCreateViewModel viewModel) { if (ModelState.IsValid) { db.Vocabularios.Add(viewModel.Vocabulario); db.SaveChanges(); if (viewModel.AudioFile != null) { viewModel.Vocabulario.FicheroAudio = viewModel.Vocabulario.VocabularioId + ".mp3"; string nameAndLocation = "~/media/upload/audio/" + viewModel.Vocabulario.FicheroAudio; viewModel.AudioFile.SaveAs(Server.MapPath(nameAndLocation)); db.Entry(viewModel.Vocabulario).State = EntityState.Modified; db.SaveChanges(); } return(RedirectToAction("Index", new { })); } viewModel.InicializarDesplegables(); return(View(viewModel)); }