Skip to content

Instantly share code, notes, and snippets.

@jonnii
Created November 26, 2012 23:43
Show Gist options
  • Save jonnii/4151406 to your computer and use it in GitHub Desktop.
Save jonnii/4151406 to your computer and use it in GitHub Desktop.
public HttpResponseMessage Post(IEnumerable<Message> messages)
{
try
{
Logger.Info("POST MessagesController::Create");
if (messages.Any(m => !m.IsValid))
{
return new HttpResponseMessage(HttpStatusCode.BadRequest)
{
ReasonPhrase = "Invalid messages"
};
}
Logger.InfoFormat("Persisting {0} messages", messages.Count());
persister.Persist(messages);
return new HttpResponseMessage(HttpStatusCode.Created);
}
catch (Exception e)
{
Logger.FatalFormat(e, "{0}", e.Message);
throw;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment