Esempio n. 1
0
 public WriteModule(ICommandDispatcher dispatcher)
     : base(dispatcher)
 {
     Post["/widgets/"] = parameters =>
     {
         var postData = this.Bind<WidgetPostModel>();
         var createWidgetCommand = new CreateWidget(Guid.NewGuid(), postData.Name);
         var respone = DispatchCommand(createWidgetCommand, HttpStatusCode.Created);
         respone.Headers.Add("location", $"/widgets/{createWidgetCommand.WidgetId}");
         return respone;
     };
 }
 public void Handle(CreateWidget message)
 {
     var widgetAggregate = new WidgetAggregate(message.WidgetId, message.Name);
     _aggregateRepository.Save(widgetAggregate);
 }