public bool EditSubCategory(SubCategoryViewModel model) { pub_SubCategoryEntity entity = AutoMapHelper.ToEntity <SubCategoryViewModel, pub_SubCategoryEntity>(model); if (entity.Id == 0) { entity.SubCategoryId = IDHelper.Create("S"); categoryRepository.InsertSubCategory(entity); } else { categoryRepository.UpdateSubCategory(entity); } return(true); }
public bool EditArticle(ArticleViewModel model) { ArticleEntity entity = AutoMapHelper.ToEntity <ArticleViewModel, ArticleEntity>(model); if (entity.Id == 0) { entity.ArticleId = IDHelper.Create("A"); articleRepository.InsertArticle(entity); } else { var last = articleRepository.GetArticleById(entity.Id); entity.CreateTime = last.CreateTime; entity.ArticleId = last.ArticleId; articleRepository.UpdateArticle(entity); } return(true); }
public ListCategoryViewModel GetListCategoryById(string id, string subid) { var result = categoryRepository.GetListCategoryById(id, subid); return(AutoMapHelper.ToEntity <ListCategoryDto, ListCategoryViewModel>(result)); }
public int InsertComment(CommentViewModel model) { ArticleCommentEntity entity = AutoMapHelper.ToEntity <CommentViewModel, ArticleCommentEntity>(model); return(articleRepository.InsertComment(entity)); }
public ArticleViewModel GetArticleByArticleId(string articleId) { var result = articleRepository.GetArticleByArticleId(articleId); return(AutoMapHelper.ToEntity <ArticleEntity, ArticleViewModel>(result)); }