private IQueryable<Order> GetListQuery(SearchListParams searchParams)
        {
            IQueryable<Order> query = _dbContext.Gig
                .Include("User")
                .Include("Category")
                .Include("SubCategory")
                .Where(x => x.Category != null && x.User != null && !x.IsDeleted && x.AcceptedTasks < x.BidLimit && x.User.Balance > x.Price);
            if (searchParams.CategoryIds != null)
                query = query.Where(x => searchParams.CategoryIds.Contains(x.Category.Id));
            if (searchParams.SubcategoryIds != null)
                query = query.Where(x => searchParams.SubcategoryIds.Contains(x.SubCategory.Id));

            if (!string.IsNullOrEmpty(searchParams.GigResponseTime) && searchParams.GigResponseTime != "ResponseTimeAny")
            {
                var gigResponseTimeEnum = OrderResponseTime.In3Days;
                switch (searchParams.GigResponseTime)
                {
                    case "ResponseTime3h": gigResponseTimeEnum = OrderResponseTime.In3Hours; break;
                    case "ResponseTime12h": gigResponseTimeEnum = OrderResponseTime.In12Hours; break;
                    case "ResponseTime24h": gigResponseTimeEnum = OrderResponseTime.In24Hours; break;
                    case "ResponseTime3d": gigResponseTimeEnum = OrderResponseTime.In3Days; break;
                }
                query = query.Where(x => x.ResponseTime == gigResponseTimeEnum);
            }
            query = query.Where(x => x.User.Rating >= searchParams.UserRatingFrom && x.User.Rating <= searchParams.UserRatingTo);
            if (!string.IsNullOrEmpty(searchParams.UserFilter))
            {
                query = query.Where(x => x.User.Id == searchParams.UserFilter);
            }
            if (!string.IsNullOrEmpty(searchParams.Title))
            {
                query = query.Where(x => x.Title.Contains(searchParams.Title));
            }
            if (!string.IsNullOrEmpty(searchParams.OrderBy))
            {
                if (searchParams.OrderBy == "highrating")
                    query = query.OrderByDescending(x => x.User.Rating).ThenByDescending(x=>x.CreateDate);
                else if (searchParams.OrderBy == "new")
                {
                    query = query.OrderByDescending(x => x.CreateDate);
                }
            }
            return query;
        }
        public List<Order> List(SearchListParams searchParams, int skip, int take, string userId)
        {
            var query = GetListQuery(searchParams);
            var orders = query.Skip(skip).Take(take).ToList();
            var orderIds = orders.Select(x => x.Id).ToList();
            if (string.IsNullOrEmpty(userId))
                return orders;
            var existingTasksOrders = _dbContext.Task
                .Include("User")
                .Include("Order")
                .Where(x => x.User.Id == userId && orderIds.Contains(x.Order.Id)).Select(x=>x.Order.Id);
            foreach (var order in orders)
            {
                if (existingTasksOrders.Contains(order.Id))
                    order.AcceptDisabled = true;
            }

            return orders;
        }
 public long ListCount(SearchListParams searchParams)
 {
     var query = GetListQuery(searchParams);
     return query.Count();
 }