public ActionResult List(PagerRequest request, HotwordSearchOption search) { int totalCount; var data = _hotwordRepo.Get(e => (!search.Type.HasValue || e.Type == search.Type.Value) && (string.IsNullOrEmpty(search.Word) || e.Word.Contains(search.Word)) && e.Status != (int)DataStatus.Deleted , out totalCount , request.PageIndex , request.PageSize , e => { if (!search.OrderBy.HasValue) { return(e.OrderByDescending(o => o.CreatedDate)); } else { switch (search.OrderBy.Value) { case GenericOrder.OrderByCreateUser: return(e.OrderByDescending(o => o.CreatedUser)); case GenericOrder.OrderByName: return(e.OrderByDescending(o => o.Word)); case GenericOrder.OrderByCreateDate: default: return(e.OrderByDescending(o => o.CreatedDate)); } } }); var models = from d in data.ToList() select new HotwordViewModel().FromEntity <HotwordViewModel>(d); return(View("List", new Pager <HotwordViewModel>(request, totalCount) { Data = models })); }
public ExecuteResult <HotWordCollectionResponse> GetCollection() { var response = new HotWordCollectionResponse(); var groupEntities = _repository.Get(v => v.Status == (int)DataStatus.Normal).Select(v => new { v.Word, v.Type, v.SortOrder }).GroupBy(v => v.Type).ToList(); var words = groupEntities.Where(v => v.Key == (int)HotWordType.Words).ToList(); var brands = groupEntities.Where(v => v.Key == (int)HotWordType.BrandStruct).ToList(); if (words.Count > 0) { var t = words[0].OrderByDescending(v => v.SortOrder).Select(v => v.Word).ToList(); response.Words = t; } if (brands.Count > 0) { var t = brands[0].OrderByDescending(v => v.SortOrder).Select(v => JsonExtension.FromJson <BrandWordsInfo>(v.Word)).ToList(); if (t.Count > 0) { response.BrandWords = t; } } var result = new ExecuteResult <HotWordCollectionResponse> { Data = response }; return(result); }