예제 #1
0
        public BlogItem Get(int id)
        {
            BlogDB.PostEntry     postEntry   = BlogDB.Get(id);
            AuthorDB.AuthorEntry authorEntry = AuthorDB.Get(postEntry.AuthorId);

            BlogItem item = new BlogItem
            {
                Id          = postEntry.Id,
                Title       = postEntry.Title,
                Text        = postEntry.Text,
                CreatedDate = postEntry.CreatedDate,
                AuthorName  = authorEntry.Name
            };

            item.SelfLink   = typeof(BlogItem).CreateUri(new { Id = postEntry.Id });
            item.UpLink     = typeof(BlogList).CreateUri();
            item.AuthorLink = typeof(Author).CreateUri(new { Id = authorEntry.Id });

            if (postEntry.ImageId != null)
            {
                item.ImageLink = typeof(Image).CreateUri(new { Id = postEntry.ImageId });
            }

            return(item);
        }
예제 #2
0
        public BlogList Get()
        {
            BlogItemHandler itemHandler = new BlogItemHandler();

            BlogList list = new BlogList
            {
                Title = "A mixed blog",
            };

            list.Items = BlogDB.GetAll().Select(entry => new BlogItem
            {
                Id          = entry.AuthorId,
                Title       = entry.Title,
                Text        = entry.Text,
                CreatedDate = entry.CreatedDate,
                SelfLink    = typeof(BlogItem).CreateUri(new { Id = entry.Id })
            }).ToList();

            AuthorDB.AuthorEntry author = AuthorDB.Get(0);

            list.AuthorName = author.Name;
            list.AuthorLink = typeof(Author).CreateUri(new { Id = author.Id });
            list.EditLink   = typeof(BlogItemCreationDescriptor).CreateUri();

            // Use relative path to verify that Ramone Links/Follow/Select etc. works with rel. paths
            list.SearchDescriptionLink = BlogConstants.SearchDescriptionSubPath;

            return(list);
        }
예제 #3
0
        public Author Get(int id)
        {
            AuthorDB.AuthorEntry entry = AuthorDB.Get(id);

            Author a = new Author
            {
                Id    = entry.Id,
                Name  = entry.Name,
                EMail = entry.EMail
            };

            a.SelfLink = typeof(Author).CreateUri(new { Id = a.Id });

            return(a);
        }