Skip to content

Instantly share code, notes, and snippets.

@dcomartin
Last active May 27, 2016 13:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dcomartin/4e04d8665bb7a4550b0023129841ffcd to your computer and use it in GitHub Desktop.
Save dcomartin/4e04d8665bb7a4550b0023129841ffcd to your computer and use it in GitHub Desktop.
public class Module : NancyModule
{
public Module(IMediator mediator)
{
Put["/customers/{CustomerId:Guid}/changepricinglevel/{MessageId:Guid}", true] = async (parameters, token) =>
{
var cmd = this.Bind<Command>();
var envelope = new Envelope<Command>((Guid)parameters.MessageId, cmd);
try
{
await mediator.SendAsync(envelope);
return HttpStatusCode.NoContent;
}
catch (Exception ex)
{
ex.ToExceptionless()
// Set the reference id of the event so we can search for it later (reference:id).
// This will automatically be populated if you call ExceptionlessClient.Default.Configuration.UseReferenceIds();
.SetReferenceId(((Guid)parameters.MessageId).ToString("N"))
// Add the envelope command object
.AddObject(envelope, "ChangePricingLevel")
// Set the customerId
.SetProperty("CustomerId", parameters.CustomerID)
// Add an Command tag.
.AddTags("Command")
// Mark critical.
.MarkAsCritical()
// Submit the event.
.Submit();
return HttpStatusCode.InternalServerError;
}
};
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment