public string createAuditLogContentPageAction(ContentPage contentPage, string action, List <string> modified_fields = null) { var _contentPage = ContentPageDbContext.getInstance().findArticleByIDNoTracking(contentPage.ArticleID); if (_contentPage == null) { return(null); } var account = SessionPersister.account; if (account == null) { return(null); } var notificationAction = EmailNotificationHelper.ParseAction(action); EmailNotificationHelper.NotifyAllOnActionOfBaseArticle("Content Page", contentPage, notificationAction); AuditLog item = new AuditLog(); item.accountID = account.AccountID; item.account = account.Username; item.contentPageID = _contentPage.ArticleID; item.contentPage = _contentPage.Name; item.categoryID = _contentPage.categoryID; item.category = _contentPage.category != null?_contentPage.category.GetName() : null; item.action = action; manipulateRemarks(item, modified_fields); return(createAuditLog(item)); }
public string delete(Category category, bool isRecursive) { using (var db = new BaseDbContext()) { var articles = ArticleDbContext.getInstance().findArticlesByCategoryID(category.ItemID); var contentPages = ContentPageDbContext.getInstance().findArticlesByCategoryID(category.ItemID); if (articles.Count > 0 || contentPages.Count > 0) { return("Could not delete this category when it is linked with any article / content page."); } if (isRecursive) { // var children = findCategorysByParentID(category.parentItemID); /// for (int i = children.Count() - 1; i >= 0; i--) // { // delete(children.ElementAt(i), true); // } } AuditLogDbContext.getInstance().createAuditLogCategoryAction(category, AuditLogDbContext.ACTION_DELETE); db.Entry(category).State = EntityState.Deleted; db.SaveChanges(); return(null); } }
// ARTICLE PUBLISHER ONLY public string tryPublishArticle(ContentPage article, bool allLocales) { var _article = ContentPageDbContext.getInstance().findArticleByVersionAndLang(article.BaseArticleID, article.Version, "en"); if (_article == null) { return("Item not found"); } if (!_article.isApproved) { return("Item not approved"); } var error = AccountGroupBaseArticlePermissionHelper.tryCatchAccountGroupPermissionError(_article); if (error != null) { return(error); } deletePublishedArticlesByBaseArticle(article); addArticleToPublished(article); db.Entry(_article).State = EntityState.Modified; _article.isPublished = true; _article.datePublished = DateTimeExtensions.GetServerTime(); _article.publishedBy = SessionPersister.account.AccountID; if (allLocales) { var _localeArticles = ContentPageDbContext.getInstance().findAllLocaleArticlesByBaseArticleAndVersion(article, article.Lang); foreach (var _a in _localeArticles) { db.Entry(_a).State = EntityState.Modified; _a.isPublished = true; _a.datePublished = DateTimeExtensions.GetServerTime(); _a.publishedBy = SessionPersister.account.AccountID; } } db.SaveChanges(); return(null); }
public string addArticleToPublished(ContentPage article) { var _article = ContentPagePublished.makeNewContentPagePublishedByCloningContent(article); _article.isPublished = true; _article.datePublished = DateTimeExtensions.GetServerTime(); getArticlePublishedDb().Add(_article); var articles = ContentPageDbContext.getInstance().findAllLocaleArticlesByBaseArticleAndVersion(article); foreach (var __article in articles) { var ___article = ContentPagePublished.makeNewContentPagePublishedByCloningContent(__article); ___article.isPublished = true; ___article.datePublished = DateTimeExtensions.GetServerTime(); getArticlePublishedDb().Add(___article); } db.SaveChanges(); return(null); }