public override string[] GetFileAttachments(Article article, EnabledStatus enabledStatus) { using (TransactionScope transaction = new TransactionScope(mConfiguration)) { FileAttachmentDataStore dataStore = new FileAttachmentDataStore(transaction); return(dataStore.GetArticleAttachments(article, enabledStatus)); } }
public override void DeleteFileAttachment(FileAttachment attachment) { using (TransactionScope transaction = new TransactionScope(mConfiguration)) { FileAttachmentDataStore dataStore = new FileAttachmentDataStore(transaction); attachment.Deleted = true; dataStore.Update(attachment); transaction.Commit(); } }
public override FileAttachment GetFileAttachment(string id) { using (TransactionScope transaction = new TransactionScope(mConfiguration)) { FileAttachmentDataStore dataStore = new FileAttachmentDataStore(transaction); FileAttachment attachment = dataStore.FindByKey(id); if (attachment == null) { throw new FileAttachNotFoundException(id); } return(attachment); } }
public override void UpdateFileAttachment(FileAttachment attachment) { //Check attachment if (attachment != null) { Attachment.FileHelper.CheckFile(attachment, attachment.Article.Category.AttachExtensions, attachment.Article.Category.AttachMaxSize); } using (TransactionScope transaction = new TransactionScope(mConfiguration)) { FileAttachmentDataStore dataStore = new FileAttachmentDataStore(transaction); dataStore.Update(attachment); transaction.Commit(); } }
public override FileAttachment GetFileAttachmentByName(Article article, string name, bool throwIfNotFound) { using (TransactionScope transaction = new TransactionScope(mConfiguration)) { FileAttachmentDataStore dataStore = new FileAttachmentDataStore(transaction); FileAttachment attachment = dataStore.FindByArticleVersion(article, name); if (attachment == null && throwIfNotFound) { throw new FileAttachNotFoundException(article.Name + "." + name); } else if (attachment == null) { return(null); } return(attachment); } }
public override FileAttachment CreateFileAttachment(Article article, string name, string contentType, byte[] contentData) { FileAttachment attachment = new FileAttachment(article, name, contentType, contentData); //Check attachment if (attachment != null) { Attachment.FileHelper.CheckFile(attachment, article.Category.AttachExtensions, article.Category.AttachMaxSize); } using (TransactionScope transaction = new TransactionScope(mConfiguration)) { ArticleDataStore dataStore = new ArticleDataStore(transaction); dataStore.Attach(article); FileAttachmentDataStore attachmentStore = new FileAttachmentDataStore(transaction); attachmentStore.Insert(attachment); transaction.Commit(); return(attachment); } }