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:
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>