public JsonResult GetList(PromoteCond cond, int page, int rows) { int total; cond.PromoteType = 1; var result = PromoteService.Instance.GetPromoteListByPage(cond, rows, page, out total); return(Json(new { rows = result.Select(x => new { x.Id, x.Content, x.Integral, x.Price, x.Operator, x.RaceType, x.SendType, x.Level, x.MatchName, x.IsSend, x.State, x.IsReturn, CreateTime = x.CreateTime.ToString(), }), total }, JsonRequestBehavior.AllowGet)); }
public List <PromoteDto> GetPromoteListByPage(PromoteCond cond, int size, int index, out int total) { var query = promoteRepository.Source.Where(x => x.PromoteType == cond.PromoteType); if (cond.StartDate != null && cond.EndDate != null) { query = query.Where(x => x.CreateTime >= cond.StartDate.Value && x.CreateTime <= cond.StartDate.Value); } if (!string.IsNullOrEmpty(cond.RaceType)) { query = query.Where(x => x.RaceType.ToString() == cond.RaceType); } if (cond.IsSend.HasValue) { query = query.Where(x => x.IsSend == cond.IsSend.Value); } query = query.OrderByDescending(x => x.CreateTime); return(promoteRepository.FindForPaging(size, index, query, out total).ToList().ToListModel <Promote, PromoteDto>()); }