Ejemplo n.º 1
0
        public IJsonApiContext ApplyContext <T>(object controller)
        {
            if (controller == null)
            {
                throw new JsonApiException(500, $"Cannot ApplyContext from null controller for type {typeof(T)}");
            }

            ControllerType = controller.GetType();

            var context = _httpContextAccessor.HttpContext;
            var path    = context.Request.Path.Value.Split('/');

            RequestEntity = ContextGraph.GetContextEntity(typeof(T));

            if (context.Request.Query.Any())
            {
                QuerySet = new QuerySet(this, context.Request.Query);
                IncludedRelationships = QuerySet.IncludedRelationships;
            }

            var linkBuilder = new LinkBuilder(this);

            BasePath           = linkBuilder.GetBasePath(context, RequestEntity.EntityName);
            PageManager        = GetPageManager();
            IsRelationshipPath = path[path.Length - 2] == "relationships";
            return(this);
        }
Ejemplo n.º 2
0
        public IJsonApiContext ApplyContext <T>()
        {
            var context = _httpContextAccessor.HttpContext;

            RequestEntity = ContextGraph.GetContextEntity(typeof(T));

            if (context.Request.Query.Any())
            {
                QuerySet = new QuerySet(this, context.Request.Query);
                IncludedRelationships = QuerySet.IncludedRelationships;
            }

            var linkBuilder = new LinkBuilder(this);

            BasePath = linkBuilder.GetBasePath(context, RequestEntity.EntityName);

            return(this);
        }
Ejemplo n.º 3
0
        public IJsonApiContext ApplyContext <T>()
        {
            var context = _httpContextAccessor.HttpContext;
            var path    = context.Request.Path.Value.Split('/');

            RequestEntity = ContextGraph.GetContextEntity(typeof(T));

            if (context.Request.Query.Any())
            {
                QuerySet = new QuerySet(this, context.Request.Query);
                IncludedRelationships = QuerySet.IncludedRelationships;
            }

            var linkBuilder = new LinkBuilder(this);

            BasePath           = linkBuilder.GetBasePath(context, RequestEntity.EntityName);
            PageManager        = GetPageManager();
            IsRelationshipPath = path[path.Length - 2] == "relationships";
            return(this);
        }