Exemple #1
0
        public async void DeleteArticle(string articleId, string accountId)
        {
            ArticleDocumentDBRepository ArticleRepository = new ArticleDocumentDBRepository();
            Article OldVersion = await ArticleRepository.Details(articleId);

            OldVersion.State = Article.Deleted;
            ArticleRepository.Update(articleId, OldVersion);

            ArticleHistoryDocumentDBRepository ArticleHistoryRepository = new ArticleHistoryDocumentDBRepository();
            ArticleHistory ArticleHistory = ArticleHistoryRepository.GetAllListWhere(f => f.ArticleId == articleId).Result.FirstOrDefault();
            ArticleHistory newHistory;

            if (ArticleHistory != null)
            {
                newHistory = SetHistory(ArticleHistory.VersionNum + 1, OldVersion, accountId);
            }
            else
            {
                newHistory = SetHistory(1, OldVersion, accountId);
            }
            ArticleHistoryRepository.Create(newHistory);
        }
Exemple #2
0
        public async void UpdateArticle(Article article, string accountId)
        {
            ArticleDocumentDBRepository ArticleRepository = new ArticleDocumentDBRepository();
            Article OldVersion = await ArticleRepository.Details(article.Id);


            article.DateUpdated = DateTime.Now.ToString("HH:mm:ss dd.MM.yyyy");
            ArticleRepository.Update(article.Id, article);

            ArticleHistoryDocumentDBRepository ArticleHistoryRepository = new ArticleHistoryDocumentDBRepository();
            ArticleHistory ArticleHistory = ArticleHistoryRepository.GetAllListWhere(f => f.ArticleId == article.Id).Result.FirstOrDefault();
            ArticleHistory newHistory;

            if (ArticleHistory != null)
            {
                newHistory = SetHistory(ArticleHistory.VersionNum + 1, OldVersion, accountId);
            }
            else
            {
                newHistory = SetHistory(1, OldVersion, accountId);
            }
            ArticleHistoryRepository.Create(newHistory);
        }