Exemple #1
0
        /// <summary>
        /// Filters a List of IRESTfulItemResult by OData parameters received in the route of the HTTP Request and returns as a RESTfulResult.
        /// </summary>
        /// <typeparam name="T">IRESTfulItemResult.</typeparam>
        /// <param name="itemsList">List of IRESTfulItemResult.</param>
        /// <param name="httpRequest">HTTP Request with the route containing OData parameters.</param>
        /// <param name="customHrefHelper">Only use if you want to make make the value of the Href property of items inside the collection different from the value of the Href of the entire collection.</param>
        /// <returns></returns>
        public RESTfulResult <T> FilterAndGetRESTfulResult <T>(List <T> itemsList, HttpRequest httpRequest, CustomHrefHelperModel customHrefHelper = null) where T : class, IRESTfulItemResult
        {
            var result = itemsList.TryFilterWithOData(oDataParamsValidator, oDataParser, httpRequest, out int count);

            return(result.ToRESTfulResult(count, httpRequest, customHrefHelper));
        }
Exemple #2
0
        public static RESTfulResult <T> ToRESTfulResult <T>(this IEnumerable <T> itemsList, int length, HttpRequest request, CustomHrefHelperModel customHrefHelper = null) where T : IRESTfulItemResult
        {
            var pathValue   = request.Path.Value;
            var queryString = request.QueryString;

            itemsList.SetHrefProperty(pathValue, customHrefHelper);

            if (queryString.HasValue)
            {
                return(new RESTfulResult <T>(itemsList, length, new Uri(pathValue + queryString, UriKind.Relative)));
            }

            return(new RESTfulResult <T>(itemsList, length, new Uri(pathValue, UriKind.Relative)));
        }
Exemple #3
0
        /// <summary>
        /// Filters an IQueryable of IRESTfulItemResult by OData parameters received in the route of the HTTP Request and returns as a RESTfulResult.
        /// </summary>
        /// <typeparam name="T">IRESTfulItemResult.</typeparam>
        /// <param name="itemsList">IQueryable of IRESTfulItemResult.</param>
        /// <param name="httpRequest">HTTP Request with the route containing OData parameters.</param>
        /// <param name="customHrefHelper">Only use if you want to make make the value of the Href property of items inside the collection different from the value of the Href of the entire collection.</param>
        /// <returns></returns>
        public async Task <RESTfulResult <T> > FilterAndGetRESTfulResultAsync <T>(IQueryable <T> itemsList, HttpRequest httpRequest, CustomHrefHelperModel customHrefHelper = null) where T : class, IRESTfulItemResult
        {
            var result = await itemsList.TryFilterWithODataAsync(oDataParamsValidator, oDataParser, httpRequest);

            return(result.ToRESTfulResult(httpRequest, customHrefHelper));
        }