public async Task <Guid> Create(ProductTrade newTrade) { // 1) raise domain events AddDomainEvent(new TradeRegisteredEvent(newTrade.Id)); // store the object await _context.ProductTrade.AddAsync(newTrade); var command = new TradeRegisteredCommand(Guid.NewGuid(), newTrade.TradeId); var domainEvent = new EventStore(); domainEvent.Id = command.Id; domainEvent.EnqueueDate = DateTime.UtcNow; domainEvent.Type = command.GetType().FullName; domainEvent.Data = JsonConvert.SerializeObject(command); await _context.EventStore.AddAsync(domainEvent); // save changes await _context.SaveChangesAsync(); return(newTrade.Id); }
public static void PrintTrade(ProductTrade t) { Console.WriteLine("{0} id:{1} price:{2} qty:{3} side:{4}", t.Time.ToDisplay(), t.TradeId, t.Price, t.Size, t.Side); }