Created
January 15, 2012 01:15
-
-
Save howarddierking/1613750 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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