public AttachmentDownloadViewModel DownloadAttachment(int receivableAttachmentId) { AttachmentDownloadViewModel attFile = new AttachmentDownloadViewModel(); FileLogic fl = new FileLogic(); var att = _fisiereServices.Get(receivableAttachmentId); if (att == null) { throw new Exception("Invalid file"); } try { attFile.FileBytes = fl.ReadFileBytesFromDisk(att.Path); attFile.FileName = att.Name; attFile.FileType = att.FileType; } catch (Exception ex) { throw new Exception("File cannot be downloaded!", ex); } return(attFile); }
public JsonResult GetAttachament(int receivableAttachemntId) { AttachmentDownloadViewModel attToBeDownload = null; try { UploadLogic cl = new UploadLogic(db); attToBeDownload = cl.DownloadAttachment(receivableAttachemntId); } catch (Exception ex) { } //return attToBeDownload; return(Json(Utils.JsonResponseFactory.SuccessResponse(attToBeDownload), JsonRequestBehavior.AllowGet)); }