public ActionResult VerAnexoAgenda(Int32 id) { if ((String)Session["Ativa"] == null) { return(RedirectToAction("Login", "ControleAcesso")); } // Prepara view AGENDA_ANEXO item = baseApp.GetAnexoById(id); return(View(item)); }
public FileResult DownloadAgenda(Int32 id) { AGENDA_ANEXO item = baseApp.GetAnexoById(id); String arquivo = item.AGAN_AQ_ARQUIVO; Int32 pos = arquivo.LastIndexOf("/") + 1; String nomeDownload = arquivo.Substring(pos); String contentType = string.Empty; if (arquivo.Contains(".pdf")) { contentType = "application/pdf"; } else if (arquivo.Contains(".jpg")) { contentType = "image/jpg"; } else if (arquivo.Contains(".png")) { contentType = "image/png"; } return(File(arquivo, contentType, nomeDownload)); }
public ActionResult UploadFileAgenda(HttpPostedFileBase file) { if ((String)Session["Ativa"] == null) { return(RedirectToAction("Login", "ControleAcesso")); } if (file == null) { ModelState.AddModelError("", OdontoWeb_Resources.ResourceManager.GetString("M0019", CultureInfo.CurrentCulture)); return(RedirectToAction("VoltarAnexoAgenda")); } AGENDA item = baseApp.GetById((Int32)Session["IdVolta"]); USUARIO usu = (USUARIO)Session["UserCredentials"]; var fileName = Path.GetFileName(file.FileName); if (fileName.Length > 250) { ModelState.AddModelError("", OdontoWeb_Resources.ResourceManager.GetString("M0024", CultureInfo.CurrentCulture)); return(RedirectToAction("VoltarAnexoAgenda")); } String caminho = "/Imagens/" + ((Int32)Session["IdVolta"]).ToString() + "/Agenda/" + item.AGEN_CD_ID.ToString() + "/Anexos/"; String path = Path.Combine(Server.MapPath(caminho), fileName); file.SaveAs(path); //Recupera tipo de arquivo extensao = Path.GetExtension(fileName); String a = extensao; // Gravar registro AGENDA_ANEXO foto = new AGENDA_ANEXO(); foto.AGAN_AQ_ARQUIVO = "~" + caminho + fileName; foto.AGAN_DT_ANEXO = DateTime.Today; foto.AGAN_IN_ATIVO = 1; Int32 tipo = 3; if (extensao.ToUpper() == ".JPG" || extensao.ToUpper() == ".GIF" || extensao.ToUpper() == ".PNG" || extensao.ToUpper() == ".JPEG") { tipo = 1; } if (extensao.ToUpper() == ".MP4" || extensao.ToUpper() == ".AVI" || extensao.ToUpper() == ".MPEG") { tipo = 2; } if (extensao.ToUpper() == ".PDF") { tipo = 3; } foto.AGAN_IN_TIPO = tipo; foto.AGAN_NM_TITULO = fileName; foto.AGEN_CD_ID = item.AGEN_CD_ID; item.AGENDA_ANEXO.Add(foto); objetoAntes = item; Int32 volta = baseApp.ValidateEdit(item, objetoAntes, usu); return(RedirectToAction("VoltarAnexoAgenda")); }
public AGENDA_ANEXO GetAnexoById(Int32 id) { AGENDA_ANEXO lista = _baseService.GetAnexoById(id); return(lista); }