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

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

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

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