Skip to content

Instantly share code, notes, and snippets.

@howarddierking
Created January 15, 2012 01:15
Show Gist options
  • Save howarddierking/1613750 to your computer and use it in GitHub Desktop.
Save howarddierking/1613750 to your computer and use it in GitHub Desktop.
public HttpResponseMessage<IEnumerable<Bug>> Post(JsonObject formData) {
dynamic data = formData.AsDynamic();
var bug = new Bug
{
Name = data.name,
Priority = data.priority,
Rank = data.rank,
};
_bugRepository.Add(bug);
var response = new HttpResponseMessage<IEnumerable<Bug>>(
_bugRepository.GetAll().Where(b => b.Status == BugStatus.Pending)
.OrderBy(b => b.Priority)
.ThenBy(b => b.Rank)) {StatusCode = HttpStatusCode.Created};
response.Headers.Location = new Uri(String.Format("{0}/bug/{1}", HostUriFromRequest(Request), bug.Id));
response.SetTemplate("pendingbugs");
return response;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment