public ActionResult List(PagerRequest request,BrandListSearchOption search, int? sort)
        {
            int totalCount;
            var linq = _brandRepository.Get(e => (!search.PId.HasValue || e.Id == search.PId.Value)
                                                   && (string.IsNullOrEmpty(search.Name) || e.Name.ToLower().StartsWith(search.Name.ToLower()))
                                                   && 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.Name);
                                                         case GenericOrder.OrderByCreateDate:
                                                         default:
                                                             return e.OrderByDescending(o => o.CreatedDate);

                                                     }
                                                 }
                                             });
            var data = linq.GroupJoin(_resourceRepository.Get(r => r.SourceType == (int)SourceType.BrandLogo),
                o => o.Id,
                i => i.SourceId,
                (o, i) => new { S = o,R = i});
            var brands = from s in data.ToList()
                         select new BrandViewModel().FromEntity<BrandViewModel>(s.S,
                         b => (b as BrandViewModel).Resource= new ResourceViewModel().FromEntity<ResourceViewModel>(s.R.FirstOrDefault()));

            var v = new BrandCollectionViewModel(request, totalCount) { Brands = brands.ToList() };

            return View("List", v);
        }
 public ActionResult Index(PagerRequest request, BrandListSearchOption search, int? sort)
 {
     return List(request,search, sort);
 }