Ejemplo n.º 1
0
        public ActionResult Edit(AudioSentenceExerciseEditViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                if (viewModel.AudioFile != null)
                {
                    string fullPath = Request.MapPath("~/media/upload/audio_ejercicio/" + viewModel.AudioSentenceExercise.FicheroAudio);
                    if (System.IO.File.Exists(fullPath))
                    {
                        System.IO.File.Delete(fullPath);
                    }
                    viewModel.AudioSentenceExercise.FicheroAudio = viewModel.AudioSentenceExercise.Id + ".mp3";

                    string nameAndLocation = "~/media/upload/audio_ejercicio/" + viewModel.AudioSentenceExercise.FicheroAudio;
                    viewModel.AudioFile.SaveAs(Server.MapPath(nameAndLocation));
                }

                viewModel.AudioSentenceExercise.Descripcion     = viewModel.AudioSentenceExercise.Enunciado.Replace("#", "______");
                db.Entry(viewModel.AudioSentenceExercise).State = EntityState.Modified;
                db.SaveChanges();
                if (viewModel.ExamenId.HasValue)
                {
                    return(RedirectToAction("Edit", "ErroresExamens", new { id = viewModel.ExamenId.Value }));
                }
                else
                {
                    return(RedirectToAction("Create", "AudioSentenceExercises", new { id = viewModel.AudioSentenceExercise.BloqueId }));
                }
            }
            viewModel.Inicializar(viewModel.AudioSentenceExercise.SubTemaId);
            return(View(viewModel));
        }
Ejemplo n.º 2
0
        // GET: Admin/AudioSentenceExercises/Edit/5
        public ActionResult Edit(int id, int?examenId)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            AudioSentenceExercise AudioSentenceExercise = db.AudioSentenceExercises.Find(id);

            if (AudioSentenceExercise == null)
            {
                return(HttpNotFound());
            }

            AudioSentenceExerciseEditViewModel viewModel = new AudioSentenceExerciseEditViewModel();

            viewModel.Inicializar(AudioSentenceExercise.BloqueId);
            viewModel.ExamenId = examenId;

            viewModel.AudioSentenceExercise = AudioSentenceExercise;
            return(View(viewModel));
        }