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; } }
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; } }
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; } }