public FileContentResult VerDocs(string tipoDoc, int profId, int titId) { var profesional = ProfVM.GetListaProfDummy().Where(r => r.profId == profId).FirstOrDefault(); string _IdMatricula = profesional.profId.ToString() + "_" + profesional.ListaTitulos.Where(r => r.titId == titId).FirstOrDefault().titMatricula.ToString(); switch (tipoDoc) { case "docTitulo": { var fullPathToFile = Server.MapPath("~/UploadedFiles/Profesionales/" + _IdMatricula + "/" + _IdMatricula + "_Titulo.pdf"); var mimeType = "application/pdf"; var fileContents = System.IO.File.ReadAllBytes(fullPathToFile); return(new FileContentResult(fileContents, mimeType)); } break; case "docAnalitico": { var fullPathToFile = Server.MapPath("~/UploadedFiles/Profesionales/" + _IdMatricula + "/" + _IdMatricula + "_Analitico.pdf"); var mimeType = "application/pdf"; var fileContents = System.IO.File.ReadAllBytes(fullPathToFile); return(new FileContentResult(fileContents, mimeType)); } break; default: return(null); break; } }
public ActionResult SubirDocs(HttpPostedFileBase docTitulo, HttpPostedFileBase docAnalitico, int profId, int titId) { try { //if (Request.Files.Count > 0) //{ // HttpFileCollectionBase files = Request.Files; // docTitulo = files[0]; // docAnalitico = files[1]; //} //if (docTitulo.ContentLength > 0) //{ // string _FileName = Path.GetFileName(docTitulo.FileName); // string _path = Path.Combine(Server.MapPath("~/UploadedFiles"), _FileName); // docTitulo.SaveAs(_path); //} //ViewBag.Message1 = "Titulo subido satisfactoriamente!!"; //if (docAnalitico.ContentLength > 0) //{ // string _FileName = Path.GetFileName(docAnalitico.FileName); // string _path = Path.Combine(Server.MapPath("~/UploadedFiles"), _FileName); // docAnalitico.SaveAs(_path); //} //ViewBag.Message2 = "Titulo subido satisfactoriamente!!"; //return PartialView(); var profesional = ProfVM.GetListaProfDummy().Where(r => r.profId == profId).FirstOrDefault(); if (Request.Files.Count > 0) { HttpFileCollectionBase files = Request.Files; string _IdMatricula = profesional.profId.ToString() + "_" + profesional.ListaTitulos.Where(r => r.titId == titId).FirstOrDefault().titMatricula.ToString(); //Titulo if (files["docTitulo"] != null) { docTitulo = files["docTitulo"]; if (docTitulo.ContentLength > 0) { string _FileName = _IdMatricula + "_Titulo" + Path.GetExtension(docTitulo.FileName); System.IO.Directory.CreateDirectory(Server.MapPath("~/UploadedFiles/Profesionales/" + _IdMatricula)); string _path = Path.Combine(Server.MapPath("~/UploadedFiles/Profesionales/" + _IdMatricula), _FileName); docTitulo.SaveAs(_path); } ViewBag.Message1 = "Titulo subido satisfactoriamente!!"; } //Analitico if (files["docAnalitico"] != null) { docAnalitico = files["docAnalitico"]; if (docAnalitico.ContentLength > 0) { string _FileName = _IdMatricula + "_Analitico" + Path.GetExtension(docAnalitico.FileName); System.IO.Directory.CreateDirectory(Server.MapPath("~/UploadedFiles/Profesionales/" + _IdMatricula)); string _path = Path.Combine(Server.MapPath("~/UploadedFiles/Profesionales/" + _IdMatricula), _FileName); docAnalitico.SaveAs(_path); } ViewBag.Message2 = "Analitico subido satisfactoriamente!!"; } return(PartialView()); } ViewBag.Message = "No se subio ningun archivo."; return(PartialView()); } catch (Exception ex) { ViewBag.Message = "Ocurrio un error! Intente nuevamente."; return(PartialView()); } }
public ActionResult SubirDocs(int profId, int titId) { var titulo = ProfVM.GetListaProfDummy().Where(r => r.profId == profId).FirstOrDefault().ListaTitulos.Where(r => r.titId == titId).FirstOrDefault(); return(PartialView(titulo)); }