Skip to content

Instantly share code, notes, and snippets.

@diegobrunetti
Last active August 29, 2015 14:06
Show Gist options
  • Select an option

  • Save diegobrunetti/64e1ac0544730082e5ff to your computer and use it in GitHub Desktop.

Select an option

Save diegobrunetti/64e1ac0544730082e5ff to your computer and use it in GitHub Desktop.
[HttpGet, Route("api/posts/{permalink}")]
public async Task<object> PostWithPermalink(string permalink)
{
var post = await _repository.FindAsync(permalink);
if (post != null)
{
return new
{
title = post.Title,
introduction = post.Introduction,
permalink = post.Permalink,
content = post.Content,
author = post.Author.Name,
date = post.PostDate.ToString("dd/MM/yyyy hh:mm"),
categories = post.Categories
};
}
throw new HttpResponseException(HttpStatusCode.NotFound);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment