protected virtual ResponseContext <K> GetByIdHATEOAS <K>(ResponseContext <K> response) where K : class, T { //TODO: Define a way to insert a generic function to overwrite //if (_getByIdHATEOAS != null) // return _getByIdHATEOAS(response); //else if (ResourceMap != null) if (ResourceMap != null) { response.ThenIf(AggregateParams.ResourceAccess(AggregateParams.Context.Principal, Actions.ReadAll), rc => rc.WithCollectionLink(ResourceMap.BuildLinkID(PluralResourceName, CRUDverbs.Read))); } return(response); }
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); }
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); }
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); }