Example #1
0
        protected override ResponseContext <IList <K> > GetAllHATEOAS <K>(ResponseContext <IList <K> > response, int page, int?pageSize)
        {
            //if (_getAllHATEOAS != null)
            //    return _getAllHATEOAS(response);
            //else if (ResourceMap != null)
            if (ResourceMap != null)
            {
                response.ThenIf(AggregateParams.ResourceAccess(AggregateParams.Context.Principal, Actions.Add), rc =>
                                rc.WithCreateRelatedLink(ResourceMap.BuildLinkID(ResourceName, CRUDverbs.Create)));
            }
            // Paging Links are added by default later on by the HATEOAS engine, unless defined here already

            return(response);

            //return base.GetAllHATEOAS(response, page, pageSize);
        }
Example #2
0
        protected override ResponseContext <K> GetByIdHATEOAS <K>(ResponseContext <K> response)
        {
            if (ResourceMap != null)
            {
                base.GetByIdHATEOAS(response).ThenIf(AggregateParams.ResourceAccess(AggregateParams.Context.Principal, Actions.Add), rc =>
                                                     rc.WithCreateRelatedLink(ResourceMap.BuildLinkID(ResourceName, CRUDverbs.Create)));
                // TODO: Find a way to inject the ID names for the model
                //
                //.ThenIf(aggregateParams.ResourceAccess(aggregateParams.Context.Principal, Actions.Update), rc =>
                //    rc.AddUpdateItemLink(ResourceMap.BuildLinkID(ResourceName, CRUDverbs.Update).withParameter( /* Need the IDs */, /* Could use the IDs send as object[] in GetById above */ )))
                //.ThenIf(aggregateParams.ResourceAccess(aggregateParams.Context.Principal, Actions.Remove), rc =>
                //    rc.AddRemoveRelatedItemLink(ResourceMap.BuildLinkID(ResourceName, CRUDverbs.Delete)));
            }

            return(response);
        }
Example #3
0
        protected virtual ResponseContext <T> AddHATEOAS(ResponseContext <T> response)
        {
            if (_addHATEOAS != null)
            {
                return(_addHATEOAS(response));
            }
            else if (ResourceMap != null)
            {
                response.ThenIf(AggregateParams.ResourceAccess(AggregateParams.Context.Principal, Actions.Add), rc =>
                                rc.WithCreateRelatedLink(ResourceMap.BuildLinkID(ResourceName, CRUDverbs.Create)))
                .ThenIf(AggregateParams.ResourceAccess(AggregateParams.Context.Principal, Actions.ReadAll), rc =>
                        rc.WithCollectionLink(ResourceMap.BuildLinkID(PluralResourceName, CRUDverbs.Read)));
            }
            // TODO: Find a way to inject the ID names for the model
            //
            //.ThenIf(aggregateParams.ResourceAccess(aggregateParams.Context.Principal, Actions.Update), rc =>
            //    rc.AddUpdateItemLink(ResourceMap.BuildLinkID(ResourceName, CRUDverbs.Update).withParameter( /* Need the IDs */, /* Could use the IDs send as object[] in GetById above */ )))
            //.ThenIf(aggregateParams.ResourceAccess(aggregateParams.Context.Principal, Actions.Remove), rc =>
            //    rc.AddRemoveRelatedItemLink(ResourceMap.BuildLinkID(ResourceName, CRUDverbs.Delete)));

            return(response);
        }
Example #4
0
 protected virtual Result OnDeleteSecurityClearance()
 {
     return(_onDeleteSecurityClearance != null?
            _onDeleteSecurityClearance(AggregateParams.Context.Principal) :
                AggregateParams.ResourceAccess(AggregateParams.Context.Principal, Actions.Remove));
 }