public ActionResult AgregarArchivo(ArchivoChoferModels ArchivoModel) { try { if (!ModelState.IsValid) { return(View(ArchivoModel)); } CatChofer_Datos Datos = new CatChofer_Datos(); if (Path.GetExtension(ArchivoModel.Archivo.FileName).ToLower() == ".heic") { ArchivoModel.UrlArchivo = Guid.NewGuid().ToString() + ".png"; ArchivoModel.NombreArchivo = ArchivoModel.Archivo.FileName.Replace(Path.GetExtension(ArchivoModel.Archivo.FileName), ".png"); } else { ArchivoModel.UrlArchivo = Guid.NewGuid().ToString() + Path.GetExtension(ArchivoModel.Archivo.FileName); ArchivoModel.NombreArchivo = ArchivoModel.Archivo.FileName; } RespuestaAjax respuesta = Datos.CHOFER_ac_Archivo(ArchivoModel, Conexion, User.Identity.Name, 1); if (respuesta.Success) { if (Path.GetExtension(ArchivoModel.Archivo.FileName).ToLower() == ".heic") { Stream oStream = ArchivoModel.Archivo.InputStream; Bitmap bmp = Auxiliar.ProcessFile(oStream); bmp.Save(Server.MapPath("~/ArchivosChofer/" + ArchivoModel.UrlArchivo)); } else { ArchivoModel.Archivo.SaveAs(Server.MapPath("~/ArchivosChofer/" + ArchivoModel.UrlArchivo)); } TempData["typemessage"] = "1"; } else { TempData["typemessage"] = "2"; } TempData["message"] = respuesta.Mensaje; return(RedirectToAction("Archivos", "CatChofer", new { id = ArchivoModel.Id_chofer, nombreChofer = respuesta.Href })); } catch (Exception ex) { TempData["typemessage"] = "2"; TempData["message"] = "Verifique sus datos."; return(RedirectToAction("Index")); } }
public ActionResult AgregarArchivo(string id_chofer) { try { if (string.IsNullOrEmpty(id_chofer.Trim())) { return(RedirectToAction("Index")); } ArchivoChoferModels Archivo = new ArchivoChoferModels(); Archivo.Id_chofer = id_chofer; return(View(Archivo)); } catch (Exception ex) { TempData["typemessage"] = "2"; TempData["message"] = "Verifique sus datos."; return(RedirectToAction("Index")); } }