protected override IQueryable <User> Filter(IQueryable <User> entities, IGetOptions options)
        {
            if (options == null)
            {
                return(entities);
            }
            if (options.Filters == null)
            {
                return(entities);
            }
            if (!options.Filters.Any())
            {
                return(entities);
            }

            var users = base.Filter(entities, options);

            var userFilters = ExtractUserSpecificFilters(options.Filters);

            if (userFilters.Any())
            {
                foreach (var filter in userFilters)
                {
                    users = users.Where(FilterPredicate(filter));
                }
            }

            return(users);
        }
Пример #2
0
        protected virtual IQueryable <TEntity> Sort(IQueryable <TEntity> entities, IGetOptions options)
        {
            if (!options.Orderings.Any())
            {
                return(entities);
            }

            return(entities.OrderBy(ToOrderByString(options.Orderings)));
        }
Пример #3
0
        protected virtual IQueryable <TEntity> GetAll(IGetOptions options)
        {
            var entities = Context.Set <TEntity>().AsQueryable();

            entities = Sort(entities, options);
            entities = Filter(entities, options);
            entities = Search(entities, options);

            return(entities);
        }
Пример #4
0
        public virtual async Task <IPagedList <TEntity> > Get(IGetOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            var entities = GetAll(options);

            return(await PagedList <TEntity> .CreateAsync(entities, options.PageNumber, options.PageSize));
        }
        protected override IQueryable <User> Search(IQueryable <User> entities, IGetOptions options)
        {
            var users = base.Search(entities, options);

            if (string.IsNullOrWhiteSpace(options.SearchQuery))
            {
                return(users);
            }

            return(users.Where(u => u.FirstName.Contains(options.SearchQuery) ||
                               u.LastName.Contains(options.SearchQuery)));
        }
Пример #6
0
 /// <summary>
 /// Makes a GET request to the specified <code>url</code>.
 /// </summary>
 /// <param name="url">The URL of the request.</param>
 /// <param name="options">The options for the call to the specified <code>url</code>.</param>
 /// <returns>Returns an instance of <see cref="SocialHttpResponse"/> representing the response.</returns>
 public virtual SocialHttpResponse DoHttpGetRequest(string url, IGetOptions options)
 {
     if (String.IsNullOrWhiteSpace(url))
     {
         throw new ArgumentNullException("url");
     }
     if (options == null)
     {
         throw new ArgumentNullException("options");
     }
     return(DoHttpGetRequest(url, options.GetQueryString()));
 }
Пример #7
0
 /// <summary>
 /// Makes a GET request to the Facebook API. If the <code>AccessToken</code> property has
 /// been specified, the access token will be appended to the query string.
 /// </summary>
 /// <param name="url">The URL to call.</param>
 /// <param name="options">The options of the request.</param>
 /// <returns>Returns an instance of <code>SocialHttpResponse</code> wrapping the response from the Facebook Graph API.</returns>
 public SocialHttpResponse DoAuthenticatedGetRequest(string url, IGetOptions options) {
     return DoAuthenticatedGetRequest(url, options == null ? null : options.GetQueryString());
 }
Пример #8
0
 /// <summary>
 /// Makes a signed request to the Twitter API based on the specified parameters.
 /// </summary>
 /// <param name="method">The HTTP method of the request.</param>
 /// <param name="url">The base URL of the request (no query string).</param>
 /// <param name="options">The options for the call to the API.</param>
 public virtual HttpWebResponse DoHttpRequest(string method, string url, IGetOptions options) {
     SocialQueryString queryString = options == null ? null : options.GetQueryString();
     return DoHttpRequest(method, url, queryString);
 }
Пример #9
0
 /// <summary>
 /// Makes a signed GET request to the specified <code>url</code>.
 /// </summary>
 /// <param name="url">The URL to call.</param>
 /// <param name="options">The options for the call to the API.</param>
 public virtual SocialHttpResponse DoHttpGetRequest(string url, IGetOptions options) {
     NameValueCollection nvc = (options == null ? null : options.GetQueryString().NameValueCollection);
     return SocialHttpResponse.GetFromWebResponse(DoHttpRequest("GET", url, nvc, null));
 }
Пример #10
0
 /// <summary>
 /// Makes an authenticated GET request to the specified URL. If an access token has been
 /// specified for this client, that access token will be added to the query string.
 /// Similar if a client ID has been specified instead of an access token, that client ID
 /// will be added to the query string. However some endpoint methods may require an access
 /// token, and a client ID will therefore not be sufficient for such methods.
 /// </summary>
 /// <param name="url">The URL to call.</param>
 /// <param name="query">The query string for the call.</param>
 public SocialHttpResponse DoAuthenticatedGetRequest(string url, IGetOptions query) {
     return DoAuthenticatedGetRequest(url, query == null ? null : query.GetQueryString());
 }
Пример #11
0
        /// <summary>
        /// Makes a signed request to the Twitter API based on the specified parameters.
        /// </summary>
        /// <param name="method">The HTTP method of the request.</param>
        /// <param name="url">The base URL of the request (no query string).</param>
        /// <param name="options">The options for the call to the API.</param>
        public virtual HttpWebResponse DoHttpRequest(string method, string url, IGetOptions options)
        {
            SocialQueryString queryString = options == null ? null : options.GetQueryString();

            return(DoHttpRequest(method, url, queryString));
        }
Пример #12
0
        /// <summary>
        /// Makes an authenticated GET request to the specified URL. The access token is
        /// automatically appended to the query string.
        /// </summary>
        /// <param name="url">The URL to call.</param>
        /// <param name="options">The options for the call to the API.</param>
        public SocialHttpResponse DoAuthenticatedGetRequest(string url, IGetOptions options) {

            // Generate a NameValueCollection for the query string
            NameValueCollection query = options.GetQueryString().NameValueCollection;

            // Append the access token or server if specified
            if (!String.IsNullOrWhiteSpace(AccessToken)) {
                // TODO: Specify access token in HTTP header instead
                query.Set("access_token", AccessToken);
            } else if (!String.IsNullOrWhiteSpace(ServerKey)) {
                query.Set("key", ServerKey);
            }

            // Make a call to the API
            return SocialHttpResponse.GetFromWebResponse(SocialUtils.DoHttpGetRequest(url, query));

        }
 /// <summary>
 /// Makes an authenticated GET request to the specified URL. If an access token has been
 /// specified for this client, that access token will be added to the query string.
 /// Similar if a client ID has been specified instead of an access token, that client ID
 /// will be added to the query string. However some endpoint methods may require an access
 /// token, and a client ID will therefore not be sufficient for such methods.
 /// </summary>
 /// <param name="url">The URL to call.</param>
 /// <param name="query">The query string for the call.</param>
 public SocialHttpResponse DoAuthenticatedGetRequest(string url, IGetOptions query)
 {
     return(DoAuthenticatedGetRequest(url, query == null ? null : query.GetQueryString()));
 }
Пример #14
0
 protected virtual IQueryable <TEntity> Search(IQueryable <TEntity> entities, IGetOptions options)
 {
     return(entities);
 }
Пример #15
0
        /// <summary>
        /// Makes a signed GET request to the specified <code>url</code>.
        /// </summary>
        /// <param name="url">The URL to call.</param>
        /// <param name="options">The options for the call to the API.</param>
        /// <returns>Returns an instance of <see cref="SocialHttpResponse"/> representing the raw response.</returns>
        public virtual SocialHttpResponse DoHttpGetRequest(string url, IGetOptions options)
        {
            NameValueCollection nvc = (options == null ? null : options.GetQueryString().NameValueCollection);

            return(DoHttpRequest("GET", url, nvc, null));
        }