private void ConnectToEventstore()
        {

            latestPosition = Position.Start;
           
            var subs = connection.SubscribeToAllFrom(latestPosition,true, HandleEvent);

           
            //subscribe to the stream of fraud alert
            connection.SubscribeToStreamFrom("PossiblyStolenCardClients", 0, true,

               (sub, e) =>
               {                                     
                   var jsonString = Encoding.UTF8.GetString(e.Event.Data);

                   JObject o = JObject.Parse(jsonString);
                   
                   var clientID = (string)o["ClientID"];

                   Bus.Publish(new ClientPossiblyStolen() { ClientID = clientID});

                   var ci = indexer.Get<ClientInformation>(clientID);

                   if (ci == null)
                       ci = new ClientInformation() { ID = clientID };

                   ci.PossiblyStolen = true;

                   indexer.Index(ci);
               }
               );
            
           
            Console.WriteLine("Indexing service started");
        }
        private void Handle(ClientCreated evt)
        {
            var ci = indexer.Get<ClientInformation>(evt.ID);

            ClientInformation clientInfo;

            if(ci==null)
                clientInfo = new ClientInformation() 
                            {                                
                               ID=evt.ID,
                               Name=evt.Name,
                               Balance=0
                            };
            else
            {
                clientInfo = ci;
                clientInfo.Balance = 0;
                clientInfo.Name = evt.Name;          
            }



            indexer.Index(clientInfo);
        }