public string SaveNewRichTextAttachment(byte[] byteArray, UserInfo userInfo) { using (VistosDbContext ctx = new VistosDbContext()) { RichTextAttachment att = new RichTextAttachment(); att.Deleted = false; att.Created = DateTime.Now; att.Modified = DateTime.Now; att.CreatedBy_FK = userInfo.UserId; att.Content = byteArray; att.UniqueGuid = Guid.NewGuid(); ctx.RichTextAttachment.Add(att); ctx.SaveChanges(); return(att.UniqueGuid.ToString()); } }
public ActionResult RichTextAttachmentGetImage(string id) { try { if (!string.IsNullOrEmpty(id)) { DocumentRepository rep = new DocumentRepository(Settings.GetInstance.SystemSettings); RichTextAttachment richTextAttachment = rep.GetRichTextAttachment(new Guid(id)); if (richTextAttachment != null) { System.IO.MemoryStream ms = null; ms = new System.IO.MemoryStream(richTextAttachment.Content); return(new FileStreamResult(ms, "image/png")); } } } catch (Exception ex) { Logger.SaveLogError(LogLevel.Error, "RichTextAttachmentGetImage", ex, null, null); return(NotFound()); } return(NotFound()); }