Ejemplo n.º 1
0
        public static dynamic ToResource(this Photo photo)
        {
            dynamic resource = photo.ToDynamic();
            var     href     = $"/api/profiles/{photo.Username}/photos/{photo.PhotoId}";

            resource._links = new {
                self = Hal.Href(href)
            };
            resource._actions = new {
                update = new {
                    name   = "Update this photo",
                    href   = href,
                    method = "PUT",
                    type   = "application/json"
                },
                upload = new {
                    name = "Upload this photo",
                    href,
                    method = "PUT",
                    type   = "image/jpeg"
                },
                delete = new {
                    name = "Delete this photo",
                    href,
                    method = "DELETE"
                }
            };
            return(resource);
        }
Ejemplo n.º 2
0
        public static dynamic ToResource(this Profile profile)
        {
            dynamic resource = profile.ToDynamic();

            resource._links = new {
                self     = Hal.Href($"/api/profiles/{profile.Username}"),
                friends  = Hal.Href($"/api/profiles/{profile.Username}/friends"),
                statuses = Hal.Href($"/api/profiles/{profile.Username}/statuses"),
                photos   = Hal.Href($"/api/profiles/{profile.Username}/photos")
            };
            resource._actions = new {
                update = new {
                    name   = "Update this profile",
                    href   = $"/api/profiles/{profile.Username}",
                    method = "PUT",
                    type   = "application/json"
                },
                delete = new {
                    name   = "Delete this profile",
                    href   = $"/api/profiles/{profile.Username}",
                    method = "DELETE"
                }
            };
            return(resource);
        }