public ActionResult subirArchivo(HttpPostedFileBase file) { List <MATERIAL_TUTORIA> tutoria = db.MATERIAL_TUTORIA.ToList(); String ruta = tutoria.Last().DIRECCION_ARCHIVO + file.FileName; subidaArchivo subir = new subidaArchivo(); String rutaSubir = Server.MapPath("~/Files/"); rutaSubir += file.FileName; subir.subirArchivo(rutaSubir, file); MATERIAL_TUTORIA tutoriaModificar = tutoria.Last(); tutoriaModificar.DIRECCION_ARCHIVO = ruta; db.MATERIAL_TUTORIA.Add(tutoriaModificar); db.Entry(tutoriaModificar).State = EntityState.Modified; db.SaveChanges(); ViewBag.tutorias = new SelectList(db.TUTORIA_CURSOS, "ID_TUTORIA_CURSOS", "DESCRIPCION"); ViewBag.correcto = subir.confirmacion; ViewBag.error = subir.error; if (subir.error != null) { db.MATERIAL_TUTORIA.Remove(tutoriaModificar); db.SaveChanges(); } return(View("crearArchivo")); }
public ActionResult crearArchivo(MATERIAL_TUTORIA archivo) { ViewBag.tutorias = new SelectList(db.TUTORIA_CURSOS, "ID_TUTORIA_CURSOS", "DESCRIPCION"); var id_tutoria = db.TUTORIA_CURSOS.Where(t => t.ID_PROFESOR == null).FirstOrDefault().ID_TUTORIA_CURSOS; archivo.ID_TUTORIA_CURSOS = id_tutoria; db.MATERIAL_TUTORIA.Add(archivo); db.SaveChanges(); return(View("subirArchivo")); }