public async Task<HttpResponseMessage> CreateGame(JObject input)
 {
     //TODO remove xml support
     var gameId = Guid.NewGuid();
     var command = new CreateGameCommand(gameId, User.Identity.Name, input.Value<string>("name"), input.Value<int>("firstTo"));
     _commandBus.Send(command);
     return Request.CreateResponse(HttpStatusCode.Created)
         .Tap(r => r.Headers.Location = new Uri(Url.Link("DefaultApi", new { id = gameId })));
 }
Пример #2
0
 public IEnumerable<IEvent> Handle(CreateGameCommand command)
 {
     return new List<IEvent>
                {
                    new GameCreatedEvent(
                        command.EntityId,
                        command.PlayerId,
                        command.Title,
                        command.FirstTo,
                        DateTime.UtcNow)
                };
 }