Instantly share code, notes, and snippets.
CreatedMarch 19, 2017 14:57
Save vladikk/86da55d0eb09d7a291b9f9a5b406f2c9 to your computer and use it in GitHub Desktop.
Command execution result object for CQRS based systems
This file contains hidden or 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
usingSystem; | |
namespaceExample | |
{ | |
publicabstractclassExecutionResult | |
{ | |
protectedExecutionResult(GuidaggregateId,GuidcommandId,DateTimeexecutedOn) | |
{ | |
AggregateId=aggregateId; | |
CommandId=commandId; | |
ExecutedOn=executedOn; | |
} | |
publicGuidAggregateId{get;privateset;} | |
publicGuidCommandId{get;privateset;} | |
publicDateTimeExecutedOn{get;privateset;} | |
publicabstractboolIsSuccess{get;} | |
publicclassSuccess:ExecutionResult | |
{ | |
publicSuccess(GuidaggregateId,GuidcommandId,DateTimeexecutedOn,intaggregateVersion):base(aggregateId,commandId,executedOn) | |
{ | |
AggregateVersion=aggregateVersion; | |
} | |
publicoverrideboolIsSuccess=>true; | |
publicintAggregateVersion{get;privateset;} | |
} | |
publicclassSuccess<TPayload>:Success | |
{ | |
publicSuccess(GuidaggregateId,GuidcommandId,DateTimeexecutedOn,intaggregateVersion,TPayloaddata):base(aggregateId,commandId,executedOn,aggregateVersion) | |
{ | |
Data=data; | |
} | |
publicTPayloadData{get;privateset;} | |
} | |
publicclassFailure:ExecutionResult | |
{ | |
publicFailure(GuidaggregateId,GuidcommandId,DateTimeexecutedOn,string[]errorMessages):base(aggregateId,commandId,executedOn) | |
{ | |
ErrorMessages=errorMessages; | |
} | |
publicoverrideboolIsSuccess=>false; | |
publicstring[]ErrorMessages{get;privateset;} | |
} | |
} | |
} |
NargiT commentedDec 7, 2018
What is the aggregatedId some kind of correlation id ?
MateuszNaKodach commentedJun 18, 2020
What is the aggregatedId some kind of correlation id ?
AggregateId is an id of an aggregate against which the command is executed. The aggregate concepts comes from Domain-Driven Design.
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment