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 virtual ResponseContext <T> UpdateHATEOAS(ResponseContext <T> response) { if (_updateHATEOAS != null) { return(_updateHATEOAS(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); }