Esempio n. 1
0
        public async Task EditArticle(Guid articleId, string title, string content, Guid[] categoryIds)
        {
            using (var articleSvc = new DAL.ArticleService())
            {
                var article = await articleSvc.GetOneByIdAsync(articleId);

                article.Title   = title;
                article.Content = content;
                await articleSvc.EditAsync(article);
            }
            using (var articleToCategorySvc = new DAL.ArticleToCategoryService())
            {
                foreach (var item in articleToCategorySvc.GetAllAsync().Where(m => m.ArticleId == articleId))
                {
                    await articleToCategorySvc.RemoveAsync(item, false);
                }
                foreach (var item in categoryIds)
                {
                    await articleToCategorySvc.CreateAsync(new Models.ArticleToCategory()
                    {
                        ArticleId = articleId, BlogCategoryId = item
                    }, false);
                }
                await articleToCategorySvc.Save();
            }
        }
Esempio n. 2
0
        public async Task GoodCount(Guid articleId)
        {
            using (var articleSvc = new DAL.ArticleService())
            {
                var data = await articleSvc.GetOneByIdAsync(articleId);

                data.GoodCount += 1;
                await articleSvc.EditAsync(data);
            }
        }