protected virtual void PrepareModel(ArticleModel model, Article article = null) { if (model == null) throw new ArgumentNullException("model"); //所有分类 model.Categories.AddRange( _categoryService.GetAllCategory().Select(t => new SelectListItem { Text = t.Name, Value = t.Id.ToString(), }) ); //所有标签 model.Tags = _articleService.GetAllTag().Select(t => new KeyValueModel { Text = t.Name, Value = t.Id.ToString() }).ToList(); //选中标签 if (article != null) { model.SelectedTags = article.Tags.Select(t => t.Id).ToList(); } }
/// <summary> /// 删除 /// </summary> /// <param name="article">文章实体</param> public virtual void DeleteArticle(Article article) { if (article == null) throw new ArgumentNullException("article"); _articleRepository.Delete(article); }
/// <summary> /// 插入 /// </summary> /// <param name="article">文章实体</param> public virtual void InsertArticle(Article article) { if (article == null) throw new ArgumentNullException("article"); _articleRepository.Insert(article); }