Example #1
0
        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);
        }
Example #2
0
        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);
        }
Example #3
0
        public ListCategoryViewModel GetListCategoryById(string id, string subid)
        {
            var result = categoryRepository.GetListCategoryById(id, subid);

            return(AutoMapHelper.ToEntity <ListCategoryDto, ListCategoryViewModel>(result));
        }
Example #4
0
        public int InsertComment(CommentViewModel model)
        {
            ArticleCommentEntity entity = AutoMapHelper.ToEntity <CommentViewModel, ArticleCommentEntity>(model);

            return(articleRepository.InsertComment(entity));
        }
Example #5
0
        public ArticleViewModel GetArticleByArticleId(string articleId)
        {
            var result = articleRepository.GetArticleByArticleId(articleId);

            return(AutoMapHelper.ToEntity <ArticleEntity, ArticleViewModel>(result));
        }