Пример #1
0
        public bool EditArticle(Guid articleId, string title, string content, Guid[] categoryIds)
        {
            Article article = _articleDAL.GetArticleById(articleId);

            article.ArticleTitle   = title;
            article.ArticleContent = content;
            _articleDAL.EditEntity(article);

            //IQueryable<ArticleToCategory> articleCategories = _articleToCategoryDAL.GetEntities(m => m.ArticleToCategoryArticleId == articleId).ToList();
            var articleCategories = _articleToCategoryDAL.GetEntities(m => m.ArticleToCategoryArticleId == articleId).ToList();

            foreach (ArticleToCategory articleToCategory in articleCategories)
            {
                _articleToCategoryDAL.DeleteEntity(articleToCategory);
            }
            // add new categories
            foreach (Guid categoryId in categoryIds)
            {
                _articleToCategoryDAL.CreateEntity(new ArticleToCategory()
                {
                    ArticleToCategoryId             = Guid.NewGuid(),
                    ArticleToCategoryCreateDateTime = DateTime.Now,
                    ArticleToCategoryIsRemoved      = 0,
                    ArticleToCategoryCategoryId     = categoryId,
                    ArticleToCategoryArticleId      = article.ArticleId
                });
            }

            return(true);
        }
Пример #2
0
 public ArticleEntity GetArticleById(int id)
 {
     return(_articleDal.GetArticleById(id));
 }