Beispiel #1
0
        protected Dictionary <string, HateoasAction> GetCollectionActions(string resourceCode)
        {
            if (string.IsNullOrEmpty(resourceCode))
            {
                throw new ArgumentNullException(nameof(resourceCode));
            }

            var hateoasActionMap  = new Dictionary <string, HateoasAction>();
            var relevantEndpoints = HateoasService.GetCollectionActions(resourceCode, Authorizator);

            foreach (Endpoint endpoint in relevantEndpoints)
            {
                HateoasAction newAction = new HateoasAction();
                newAction.Method = endpoint.HttpMethod;
                newAction.Href   = "/" + endpoint.UrlTemplate;

                hateoasActionMap.Add(endpoint.EndpointName, newAction);
            }

            return(hateoasActionMap);
        }
Beispiel #2
0
        protected Dictionary <string, HateoasAction> GetElementActions(IApiResource resource)
        {
            if (resource == null)
            {
                throw new ArgumentNullException(nameof(resource));
            }

            var hateoasActionMap  = new Dictionary <string, HateoasAction>();
            var relevantEndpoints = HateoasService.GetElementActions(resource, Authorizator);

            foreach (Endpoint endpoint in relevantEndpoints)
            {
                HateoasAction newAction = new HateoasAction();
                newAction.Method = endpoint.HttpMethod;
                newAction.Href   = "/" + endpoint.UrlTemplate;

                newAction.Href = ReflectionUtils.ReplaceUrlTemplate(newAction.Href, resource);

                hateoasActionMap.Add(endpoint.EndpointName, newAction);
            }

            return(hateoasActionMap);
        }