示例#1
0
 internal void Save(StockItem item)
 {
     foreach (var e in item.GetChanges())
     {
         var p  = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(e));
         var ev = new EventData(Guid.NewGuid(), e.GetType().Name, true, p, null);
         _writeModel.AppendToStreamAsync($"Stock-{item.Id}", ExpectedVersion.Any, ev).Wait();
     }
 }
示例#2
0
 protected void RefreshReadModel(StockItem StockItem)
 {
     foreach (var item in StockItem.GetChanges())
     {
         if (item.GetType().Name == "StockItemCreatedEvent")
         {
             Repository.SaveCreatedStockItem(StockItem);
         }
         if (item.GetType().Name == "StockItemSoldEvent" || item.GetType().Name == "StockItemDisposedEvent")
         {
             Repository.DeleteStockItem(StockItem);
         }
     }
 }