public void Bootstrap()
        {
            IEventStoreConnection esConnection = EventStoreConnection.Create("ConnectTo=tcp://admin:changeit@localhost:1113");

            conn = new EventStoreConnectionWrapper(esConnection);
            esConnection.Connected += (_, __) => Console.WriteLine("Connected");
            esConnection.ConnectAsync().Wait();
            IStreamNameBuilder namer = new PrefixedCamelCaseStreamNameBuilder();
            IEventSerializer   ser   = new JsonMessageSerializer();

            repo = new StreamStoreRepository(namer, conn, ser);
            OrderAggregate order = null;

            IListener listener = new StreamListener("Order", conn, namer, ser);

            _readModel = new OrderReadModel(() => listener);
        }
        public CommandResponse Handle(CreateOrderCommand command)
        {
            try
            {
                if (_repo.TryGetById <OrderAggregate>(command.Id, out var _))
                {
                    throw new ValidationException("An order with this ID already exists");
                }

                var account = new OrderAggregate(command.Id, command.Action, command.Quantity, command.Asset, command.Price);

                _repo.Save(account);
                return(command.Succeed());
            }
            catch (Exception e)
            {
                return(command.Fail(e));
            }
        }