Пример #1
0
 private static void OnPatchArticle(object?sender, PatchArticleEventArgs e)
 {
     using var db = new BloggingContext();
     if (e.Patch.ArticleTags != null)
     {
         var articleTags = e.Patch.ArticleTags.Select(articleTag =>
                                                      new ArticleTag {
             ArticleId = e.TargetArticle.Id, TagId = articleTag.TagId
         }).ToList();
         e.TargetArticle.ArticleTags = articleTags;
     }
 }
Пример #2
0
        private static void OnPatchArticle(object?sender, PatchArticleEventArgs e)
        {
            using var db = new BloggingContext();
            if (e.Patch.ArticleCategories != null)
            {
                var articleCategories = new List <ArticleCategory>();
                foreach (var articleCategory in e.Patch.ArticleCategories)
                {
                    articleCategories.Add(new ArticleCategory
                    {
                        ArticleId = e.TargetArticle.Id, CategoryId = articleCategory.CategoryId
                    });
                }

                e.TargetArticle.ArticleCategories = articleCategories;
            }
        }
Пример #3
0
        private static void OnPatchArticle(object?sender, PatchArticleEventArgs e)
        {
            using var db = new BloggingContext();
            if (e.Patch.ArticleAttachments != null)
            {
                var articleAttachments = new List <ArticleAttachment>();
                foreach (var articleAttachment in e.Patch.ArticleAttachments)
                {
                    articleAttachments.Add(new ArticleAttachment
                    {
                        ArticleId = e.TargetArticle.Id, AttachmentId = articleAttachment.AttachmentId
                    });
                }

                e.TargetArticle.ArticleAttachments = articleAttachments;
            }
        }