public JsonResult ListP(OrderSearchOption search, PagerRequest request)
        {
            int totalCount;
            search.CurrentUser = CurrentUser.CustomerId;
            search.CurrentUserRole = CurrentUser.Role;
            var dbContext = _orderRepo.Context;
            var linq = dbContext.Set<OrderEntity>().Where(p => (string.IsNullOrEmpty(search.OrderNo) || p.OrderNo == search.OrderNo) &&
                (!search.CustomerId.HasValue || p.CustomerId == search.CustomerId.Value) &&
                (!search.Status.HasValue || p.Status == (int)search.Status.Value) &&
                     (!search.Store.HasValue || p.StoreId == search.Store.Value) &&
                      (!search.Brand.HasValue || p.BrandId == search.Brand.Value) &&
                      (!search.FromDate.HasValue || p.CreateDate >= search.FromDate.Value) &&
                      (!search.ToDate.HasValue || p.CreateDate <= search.ToDate.Value) &&
                p.Status != (int)DataStatus.Deleted);
            linq = _userAuthRepo.AuthFilter(linq, search.CurrentUser, search.CurrentUserRole) as IQueryable<OrderEntity>;

            var linq2 = linq.Join(dbContext.Set<UserEntity>().Where(u => u.Status != (int)DataStatus.Deleted),
                    o => o.CustomerId,
                    i => i.Id,
                    (o, i) => new { O = o, C = i })
                .GroupJoin(dbContext.Set<RMAEntity>(),
                    o => o.O.OrderNo,
                    i => i.OrderNo,
                    (o, i) => new { O = o.O, C = o.C, RMA = i })
                .GroupJoin(dbContext.Set<ShipViaEntity>().Where(s => s.Status != (int)DataStatus.Deleted),
                    o => o.O.ShippingVia,
                    i => i.Id,
                    (o, i) => new { O = o.O, C = o.C, RMA = o.RMA, S = i.FirstOrDefault() });
              


            totalCount = linq2.Count();

            var skipCount = (request.PageIndex - 1) * request.PageSize;

            var linq3 = skipCount == 0 ? linq2.OrderByDescending(l => l.O.CreateDate).Take(request.PageSize) : linq2.OrderByDescending(l => l.O.CreateDate).Skip(skipCount).Take(request.PageSize);


            var vo = from l in linq3.ToList()
                     select new OrderViewModel().FromEntity<OrderViewModel>(l.O, p =>
                     {
                         p.ShippingViaMethod = l.S;
                         p.Customer = new CustomerViewModel().FromEntity<CustomerViewModel>(l.C);
                        
                         p.ShippingViaMethod_Name = l.S==null?string.Empty:l.S.Name;
                         p.RMAs = l.RMA.ToList().OrderByDescending(r=>r.CreateDate).Select(r => new RMAViewModel().FromEntity<RMAViewModel>(r));

                     });

            var v = new Pager<OrderViewModel>(request, totalCount) { Data = vo.ToList() };
            return Json(v);
        }
        public ActionResult List(OrderSearchOption search)
        {

            return View(search);
        }