VB Magic

2012/12/12

Just a quick update … It begins

Filed under: VB.NET — Tags: , , , , — vbmagic @ 11:26 am

The OData feed now has it’s first collection. As an initial test I created a news feed to keep the website updated on progress. I’ve not done the code to update the news feed just yet as I’m investigating securing WCF Rest services with the Azure ACS (Planning to go through the Windows Identity Foundation Patterns: On-Premise and Cloud Pluralsight course to help with this)

But the website now consumes this feed by displaying the last 5 news articles on the front page:

https://tyranntrpg.org/

This is the code in the controller that accesses the service:

    Private Const CODEXURL As String = "https://tyranntrpg.org:8443/OData/Codex.svc"
    Private _codexContext As New TranntCodexServiceReference.GlobalDbContext(New Uri(CODEXURL))

    Function Index() As ActionResult
        Dim model As List(Of NewsArticle)

        model = (From a In _codexContext.NewsArticles
                Order By a.DateAdded
                Select a).Take(5).ToList

        Return View(model)
    End Function

And this is the code in the Razor View which displays it:

    <li>
        <h4>Latest News</h4>
        <ul>
            @For Each a In Model
                @<li>@a.DateAdded.Date.ToLongDateString : <b>@a.Subject</b>
                    <p>@a.Body</p>
                 </li>
            Next
        </ul>
    </li>

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: