Exemple #1
0
        protected override IEnumerable <LinkDto> CreateLinksForSingleResource(IIdsSet rawIds, string fields)
        {
            var ids   = rawIds as PostIdsSet;
            var links = new List <LinkDto>();

            if (string.IsNullOrWhiteSpace(fields))
            {
                links.Add(new LinkDto(Url.Link("GetPost",
                                               new { ids.authorId, ids.postId }), "self", "GET"));
            }
            else
            {
                links.Add(new LinkDto(Url.Link("GetPost",
                                               new { ids.authorId, ids.postId, fields }), "self", "GET"));
            }

            links.Add(new LinkDto(Url.Link("CreatePost",
                                           new { ids.authorId }), "create_post", "POST"));

            links.Add(new LinkDto(Url.Link("UpdatePost",
                                           new { ids.authorId, ids.postId }), "update_post", "PUT"));

            links.Add(new LinkDto(Url.Link("GetPost",
                                           new { ids.authorId, ids.postId }), "patch_post", "PATCH"));

            links.Add(new LinkDto(Url.Link("GetPost",
                                           new { ids.authorId, ids.postId }), "detele_post", "DELETE"));

            return(links);
        }
Exemple #2
0
        protected IDictionary <string, object> GetLinkedResource
            (ExpandoObject shapedResource, IIdsSet idsSet, string fields = "")
        {
            var links          = CreateLinksForSingleResource(idsSet, fields);
            var linkedResource = shapedResource as IDictionary <string, object>;

            linkedResource.Add("links", links);
            return(linkedResource);
        }
        protected override IEnumerable <LinkDto> CreateLinksForSingleResource(IIdsSet rawIds, string fields)
        {
            var ids   = rawIds as AuthorIdsSet;
            var links = new List <LinkDto>();

            if (string.IsNullOrWhiteSpace(fields))
            {
                links.Add(new LinkDto(Url.Link("GetAuthor",
                                               new { ids.authorId }), "self", "GET"));
            }
            else
            {
                links.Add(new LinkDto(Url.Link("GetAuthor",
                                               new { ids.authorId, fields }), "self", "GET"));
            }

            return(links);
        }
Exemple #4
0
 protected abstract IEnumerable <LinkDto> CreateLinksForSingleResource
     (IIdsSet ids, string fields);