public async Task <IPagedList <T> > GetPagedResult(int pageIndex, int pageSize, Expression <Func <T, bool> > filter, string orderProperty = "", bool asc = true)
        {
            Expression <Func <T, object> > orderLambda = x => x.Id;

            if (!string.IsNullOrWhiteSpace(orderProperty))
            {
                System.Reflection.PropertyInfo prop = typeof(T).GetProperty(orderProperty);
                orderLambda = x => prop.GetValue(x, null);
            }

            var totalCount = await _repository.CountAll();

            var filteredCount = await _repository.CountWhere(filter);

            IPagedList <T> result = new PagedList <T>(
                _repository.Query().Where(filter).OrderBy(orderLambda)
                .Skip((pageIndex - 1) * pageSize)
                .Take(pageSize),
                pageIndex,
                pageSize,
                filteredCount,
                totalCount);

            return(result);
        }