public JsonResult GetArticleList(int page, int pageSize, string keywords = "", string cateindex = "", int isrec = -1) { ResultDto <List <Dto.ArticleDto> > result = new ResultDto <List <Dto.ArticleDto> >(); ArticlesService article = new ArticlesService(); var item = article.GetListOrderByTime(page, pageSize, o => o.TenantId == tenant.Id && o.Category.CategoryIndex == cateindex); if (isrec >= 0) { bool rec = isrec > 0; item.datas = item.datas.Where(o => o.IsRecommend == rec).ToList(); } result = Mapper.Map <ResultDto <List <Dto.ArticleDto> > >(item); article.Dispose(); return(Json(result)); }
public JsonResult GetPageLists(int page, int pageSize, string keywords = "") { ArticlesService Article = new ArticlesService(); ResultDto <List <Articles> > result = new ResultDto <List <Articles> >(); if (string.IsNullOrEmpty(keywords)) { result = Article.GetListOrderByTime(page, pageSize, (o => o.TenantId == TenantId)); } else { result = Article.GetListOrderByTime(page, pageSize, (o => o.TenantId == TenantId && o.Title.Contains(keywords))); } var lists = Mapper.Map <ResultDto <List <Dto.ArticleDto> > >(result); Article.Dispose(); return(Json(lists)); }
public JsonResult GetCount() { Dto.SiteDto result = new Dto.SiteDto(); ArticlesService ArtServ = new ArticlesService(); MembersService MembServ = new MembersService(); SignUpBespeakService SignServ = new SignUpBespeakService(); ProductsService ProdServ = new ProductsService(); result.ArticleCount = ArtServ.Reposity.GetAllList(o => o.TenantId == TenantId).Count; result.MemberCount = MembServ.Reposity.GetAllList(o => o.TenantId == TenantId).Count; result.SignCount = SignServ.Reposity.GetAllList(o => o.TenantId == TenantId).Count; result.ProductCount = ProdServ.Reposity.GetAllList(o => o.TenantId == TenantId).Count; ArtServ.Dispose(); MembServ.Dispose(); SignServ.Dispose(); ProdServ.Dispose(); return(Json(result)); }
public JsonResult CreateOrUpdate(ArticleInput model) { ResultDto <long> result = new ResultDto <long>(); try { ArticlesService ArticleRead = new ArticlesService(); ArticlesService Article = new ArticlesService(); CategoriesService Category = new CategoriesService(); var input = Mapper.Map <Articles>(model); if (input.Id == 0) { input.CreationTime = DateTime.Now; } else { input.Category = Category.Reposity.Get(input.CategoryId); //input.UpdateTime = DateTime.Now; input.CreationTime = ArticleRead.Reposity.Get(input.Id).CreationTime; } input.Contents = HttpUtility.HtmlDecode(input.Contents); input.TenantId = TenantId; Article.Reposity.InsertOrUpdate(input); result.code = 100; result.datas = input.Id; result.message = "ok"; Category.Dispose(); Article.Dispose(); ArticleRead.Dispose(); } catch (Exception ex) { result.code = 500; result.message = ex.Message; } return(Json(result)); }