public override Article CreateArticle(Category category, string owner, string name, string fileName, string title, string description, string body, bool isUpload, bool isEnabled, bool isNumbChaps, bool isAckRequired) { using (TransactionScope transaction = new TransactionScope(mConfiguration)) { ArticleDataStore articleStore = new ArticleDataStore(transaction); if (articleStore.FindByName(name) != null) { throw new ArticleNameAlreadyExistsException(name); } CategoryDataStore dataStore = new CategoryDataStore(transaction); dataStore.Attach(category); Article article = new Article(category, name, fileName, owner, title, description, body, isUpload, isEnabled, isNumbChaps); article.Author = owner; //article.Tag = isAckRequired.ToString(); article.RequiresAck = isAckRequired; if (category.AutoApprove) { article.Approved = true; } articleStore.Insert(article); transaction.Commit(); return(article); } }
public override IList <Article> GetArticles(Category category, ArticleStatus status, bool recursive) { IList <Article> articles = null; using (TransactionScope transaction = new TransactionScope(mConfiguration)) { ArticleDataStore dataStore = new ArticleDataStore(transaction); articles = dataStore.FindByCategoryAndOwner(category, null, status); if (recursive) { // Find children of this parent category. CategoryDataStore ds = new CategoryDataStore(transaction); IList <Category> childCategories = ds.FindByChildOfCategory(category.Id); foreach (Category subCategory in childCategories) { IList <Article> subArticles = dataStore.FindByCategoryAndOwner(subCategory, null, status); foreach (Article subArticle in subArticles) { articles.Add(subArticle); } } } } return(articles); }
public override void DeleteCategory(Category category) { using (TransactionScope transaction = new TransactionScope(mConfiguration)) { CategoryDataStore dataStore = new CategoryDataStore(transaction); // Delete should only be allowed if the following conditions are true: // 1. There are no child categories. if (dataStore.FindByChildOfCategory(category.Id).Count > 0) { throw new SchemaIntegrityException("Category has child categories"); } // 2. There are no articles associated with this category. ArticleDataStore ads = new ArticleDataStore(transaction); if (ads.FindByCategory(category).Count > 0) { throw new SchemaIntegrityException("Articles are associated with this category"); } // Delete all access items. AccessLayer.AccessDataStore accessDs = new AccessLayer.AccessDataStore(transaction); IList <AccessLayer.Access> allAccess = accessDs.FindAllByItem(category.Id); foreach (AccessLayer.Access access in allAccess) { access.Deleted = true; accessDs.Update(access); } category.Deleted = true; dataStore.Update(category); transaction.Commit(); } }
public override IList <Category> GetAllCategoriesBelow(string id) { using (TransactionScope transaction = new TransactionScope(mConfiguration)) { CategoryDataStore dataStore = new CategoryDataStore(transaction); return(dataStore.FindByChildOfCategory(id)); } }
public override IList <Category> GetAllCategories() { using (TransactionScope transaction = new TransactionScope(mConfiguration)) { CategoryDataStore dataStore = new CategoryDataStore(transaction); return(dataStore.FindAll()); } }
public override IList <Category> GetCategoryByLikeName(string name, bool throwIfNotFound) { using (TransactionScope transaction = new TransactionScope(mConfiguration)) { CategoryDataStore dataStore = new CategoryDataStore(transaction); IList <Category> categories = dataStore.FindByLikeName(name); return(categories); } }
public override Category GetCategoryByName(string name, bool throwIfNotFound) { using (TransactionScope transaction = new TransactionScope(mConfiguration)) { CategoryDataStore dataStore = new CategoryDataStore(transaction); Category category = dataStore.FindByName(name); return(category); } }
public override void UpdateCategory(Category category) { using (TransactionScope transaction = new TransactionScope(mConfiguration)) { CategoryDataStore dataStore = new CategoryDataStore(transaction); dataStore.Update(category); transaction.Commit(); } }
public override Category CreateCategory(string displayName) { using (TransactionScope transaction = new TransactionScope(mConfiguration)) { CategoryDataStore dataStore = new CategoryDataStore(transaction); Category category = new Category(displayName); dataStore.Insert(category); transaction.Commit(); return(category); } }
public override Category GetCategory(string id) { using (TransactionScope transaction = new TransactionScope(mConfiguration)) { CategoryDataStore dataStore = new CategoryDataStore(transaction); Category category = dataStore.FindByKey(id); if (category == null) { throw new DocoCategoryNotFoundException(id); } return(category); } }