public override int CalculateVersion() { if (CustomerIdentifier == null) { return(0); } return(CustomerIdentifier.GetHashCode()); }
public static Order Create( IAggregateContext context, OrderIdentifier orderIdentifier, CustomerIdentifier customerIdentifier) { return(CreateWithEvent <Order, OrderCreated>( context, new OrderCreated( orderIdentifier, customerIdentifier))); }
private Order CreateOrder() { if (_eventStore == null) { throw new Exception("Event store is null"); } var orderRepository = new OrderRepository(_eventStore, _aggregateContext); _order = Order.Create( _aggregateContext, OrderIdentifier.New(), CustomerIdentifier.New()); return(_order); }
public Task <IActionResult> PostIdentifier([FromBody] CustomerIdentifier identifier) { throw new NotImplementedException(); }
public List <Customer> Load(ISqlConnectionInfo connection, Service service, string value, CustomerIdentifier identifier) { SqlQueryParameters parameters = new SqlQueryParameters(); string parameter = string.Format("{0}", identifier.ToString()); parameters.Where = string.Format("[c].{0} = @{0}", parameter); if (service != null) { parameters.Where += " AND [c_s].ServiceID = @ServiceID"; parameters.Arguments.Add("ServiceID", service.ID); } parameters.OrderBy = "[c].Created DESC"; parameters.Arguments.Add(parameter, value); return(this.LoadMany(connection, parameters)); }
public List <Customer> Load(IConnectionInfo connection, Service service, string value, CustomerIdentifier identifier) { ISqlConnectionInfo sqlConnection = connection as ISqlConnectionInfo; if (sqlConnection != null) { return(this.Load(sqlConnection, service, value, identifier)); } using (sqlConnection = new SqlConnectionInfo(connection, this.Type)) return(this.Load(sqlConnection, service, value, identifier)); }
public List <Customer> Load(Service service, string value, CustomerIdentifier identifier) { using (SqlConnectionInfo connection = new SqlConnectionInfo(this.Type)) return(this.Load(connection, service, value, identifier)); }
public override Core.OrderManagement.Orders.Events.OrderCreated ConvertToIntern(OrderCreated e) { return(new Core.OrderManagement.Orders.Events.OrderCreated( OrderIdentifier.Parse(e.OrderIdentifier), CustomerIdentifier.Parse(e.CustomerIdentifier))); }
public void GivenIHaveAnOrder() { AddEvent(new OrderCreated(_orderIdentifier, CustomerIdentifier.New())); }
static async Task Main() { var eventsConverter = new EventsConverter(); //var e = new Core.OrderManagement.Orders.Events.OrderCreated(OrderIdentity.New()); //System.Console.WriteLine(JsonSerializer.Serialize(e, new JsonSerializerOptions { WriteIndented = true })); //var a = EventMapping.Convert(e); //var json = JsonSerializer.Serialize(a, new JsonSerializerOptions { WriteIndented = true, Converters = { new IdentityJsonConverter() } }); //System.Console.WriteLine(json); //var data2 = JsonSerializer.Deserialize<OrderCreated>(json); //var e2 = EventMapping.Convert2(data2); //System.Console.WriteLine(JsonSerializer.Serialize(e, e.GetType(), new JsonSerializerOptions { WriteIndented = true })); //return; var aggregateContext = new AggregateContext(); IEventStore eventStore = new EventStoreDb(eventsConverter, new Uri("http://localhost:2113")); var productRepository = new ProductRepository(eventStore, aggregateContext); var product1 = Product.Create(aggregateContext, ProductName.Create("Brood")); await productRepository.SaveAsync(product1); product1.ChangeName(ProductName.Create("Boterham")); await productRepository.SaveAsync(product1); var productRepository2 = new ProductRepository(eventStore, aggregateContext); var product1A = await productRepository2.GetAsync(product1.Identifier); //System.Console.WriteLine(JsonSerializer.Serialize(product, new JsonSerializerOptions { WriteIndented = true })); //System.Console.WriteLine(JsonSerializer.Serialize(product2, new JsonSerializerOptions { WriteIndented = true })); var orderRepository = new OrderRepository(eventStore, aggregateContext); var order = Order.Create( aggregateContext, OrderIdentifier.New(), CustomerIdentifier.New()); var faultyLine = order.CreateOrderLine(ProductIdentifier.New(), 1); faultyLine.Remove(); var prod2 = ProductIdentifier.New(); var prod3 = ProductIdentifier.New(); var prod4 = ProductIdentifier.New(); order.CreateOrderLine(product1, 1); order.CreateOrderLine(prod2, 2); order.CreateOrderLine(prod3, 1); order.CreateOrderLine(prod4, 1); var prod3OrderLine = order.Lines.Get(prod3); prod3OrderLine.Remove(); var prod1OrderLine = order.Lines.Get(product1.Identifier); prod1OrderLine.AdjustQuantity(3); await orderRepository.SaveAsync(order); var order2 = await orderRepository.GetAsync(order.OrderIdentifier); var product1B = await productRepository2.GetAsync(product1.Identifier); product1B.ChangeName(ProductName.Create("Stok brood")); await productRepository2.SaveAsync(product1B); }
public OrderCreated(OrderIdentifier orderIdentifier, CustomerIdentifier customerIdentifier) { OrderIdentifier = orderIdentifier; CustomerIdentifier = customerIdentifier; }