public JsonResult GetList(int PageIndex = 1, int PageSize = 10) { OperationResult oper = new OperationResult(OperationResultType.Error, "服务器忙,请稍后"); try { string strId = Request["Id"]; int id = int.Parse(strId); ArticleItem articleItem = _articleItemContract.View(id); List <int> listId = articleItem.Children.Select(x => x.Id).ToList(); IQueryable <Article> listArticle = _articleContract.Articles.Where(x => x.IsDeleted == false && x.IsEnabled == true && listId.Contains(x.ArticleItemId)); listArticle = listArticle.OrderBy(x => x.IsHot || x.IsRecommend || x.IsTop).ThenByDescending(x => x.Hits).OrderByDescending(x => x.UpdatedTime); IQueryable <Article> listArt = listArticle.Skip((PageIndex - 1) * PageSize).Take(PageSize); IQueryable <Administrator> listAdmin = _adminContract.Administrators; IQueryable <Member> listMember = _memberContract.Members; var entity = (from ar in listArt join ad in listAdmin on ar.AdminId equals ad.Id join me in listMember on ad.Member.MemberName equals me.UniquelyIdentifies select new { ar.Id, ar.ArticlePath, ar.CoverImagePath, CreatedTime = ar.CreatedTime, ar.Hits, ar.Title, AdminName = ad.Member.MemberName, me.UserPhoto, ar.Summary, }).ToList(); var data = entity.Select(x => new { x.Id, x.ArticlePath, x.CoverImagePath, CreatedTime = x.CreatedTime.ToString("yyyy-MM-dd"), x.Hits, x.Title, x.AdminName, x.UserPhoto, x.Summary, }); oper.ResultType = OperationResultType.Success; oper.Data = data; oper.Message = "获取成功"; return(Json(oper)); } catch (Exception ex) { _Logger.Error <string>(ex.ToString()); return(Json(oper)); } }
/// <summary> /// 查看数据详情 /// </summary> /// <returns></returns> public ActionResult View(int Id) { var result = _articleItemContract.View(Id); return(PartialView(result)); }