public ActionResult CreateContenido(Recurso recurso, HttpPostedFileBase file) { if (ModelState.IsValid) { var seq = db.Recursos.Where(x => x.MateriaId == recurso.MateriaId && x.CursoId == recurso.CursoId).Count(); // Verify that the user selected a file if (file != null && file.ContentLength > 0) { var fileName = String.Format("{0}.{1}.pdf", recurso.MateriaId, recurso.CursoId); // System.IO.Path.GetFileName(file.FileName); recurso.codigo = fileName; FTP.uploadFileUsingFTP("ftp://laggel.site90.com/public_html/PDF/" + fileName, file, "a7673407", "Laggel007"); } db.Recursos.Add(recurso); db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.CursoId = new SelectList(db.Cursos, "CursoId", "Descripcion", recurso.CursoId); ViewBag.MateriaId = new SelectList(db.Materias, "MateriaId", "Descripcion", recurso.MateriaId); return View(recurso); }
public ActionResult Edit(Recurso recurso) { if (ModelState.IsValid) { db.Entry(recurso).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.CursoId = new SelectList(db.Cursos, "CursoId", "Descripcion", recurso.CursoId); ViewBag.MateriaId = new SelectList(db.Materias, "MateriaId", "Descripcion", recurso.MateriaId); return View(recurso); }