Files
silver-octo-spoon/wolverine/getting-started/CreateIssueHandler.cs
T

23 lines
746 B
C#

namespace WolverineTutorial;
public class CreateIssueHandler(IssueRepository repository)
{
// The IssueCreated event message being returned will be
// published as a new "cascaded" message by Wolverine after
// the original message and any related middleware has
// succeeded
public IssueCreated Handle(CreateIssue command)
{
var issue = new Issue(Guid.NewGuid(), command.Title, command.Description, true, DateTimeOffset.Now,
command.OriginatorId
);
repository.Store(issue);
return new IssueCreated(issue.Id);
}
}
public record Issue(Guid Id, string Title, string Description, bool IsOpen, DateTimeOffset Opened, Guid OriginatorId);
public record IssueCreated(Guid Id);