Last active
May 27, 2016 13:45
-
-
Save dcomartin/4e04d8665bb7a4550b0023129841ffcd 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 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