public void Apply(ProductNameChanged e) { var product = GetById(e.Id); product.Name = e.NewName; product.Version = e.Version; repository.Update(product); }
public void ChangeProductName(ChangeProductNameCommand cmd) { if (_products.Any(x => x.Id == cmd.ProductId)) { var @event = new ProductNameChanged(cmd.ProductId, cmd.Name); Apply(@event); Dispatch(@event); } }
public void Should_change_name_when_a_namechanged_event_is_applied() { var p = new Product(Guid.NewGuid(), "name", "description", 1.2m); var e = new ProductNameChanged(p.Id, "new Name"); p.AsDynamic().Apply(e); Assert.Equal("new Name", p.Name); }
public void Apply(ProductNameChanged e) { var product = GetById(e.Id); product.Name = e.NewName; product.Version = e.Version; product.DisplayName = string.Format(displayFormat, product.Name, product.Description); repository.Update(product); }
private void When(ProductNameChanged e) { if (e == null) { throw new ArgumentNullException(nameof(e)); } var product = Products.FirstOrDefault(x => x.Id == e.Id); if (product != null) { product.Name = e.Name; } }
public void Given_Product_Then_Name_Should_Be_Changed() { var productId = Guid.NewGuid(); var name = Random <string>(); var @event = new ProductNameChanged(productId, name); new ScenarioForExisting <Product>() .Given(() => Product.Create(productId, Random <string>())) .When(product => { product.ChangeName(name); }) .ThenAssert(@event) .AlsoAssert(product => product.Name == name); }
public void AlterTitle(ProductNameChanged e, int version) { ApplyEvent(e, version); }
public void Apply(ProductNameChanged e) { var product = GetById(e.Id); product.Name = e.NewName; }
public void Apply(ProductNameChanged productNameChanged) { this.Name = productNameChanged.Name; }
private void When(ProductNameChanged e) { var product = _products.Where(x => x.Id == e.Id).FirstOrDefault(); product.ChangeName(e.Name); }
protected bool Equals(ProductNameChanged other) => base.Equals(other) && Name == other.Name && OccurredOn.Equals(other.OccurredOn) && Version == other.Version;
public void WhenProductNameChanged(ProductNameChanged @event) { Name = @event.Name; }
private void When(ProductNameChanged @event) { Name = @event.Name; }
public async Task SendProductNameChanged(ProductNameChanged Event) { await Clients.All.SendAsync(SendMethods.ProductNameChange.ToString(), Event); }
private void Apply(ProductNameChanged e) { Name = e.NewName; }
private void Handle(ProductNameChanged payload) { Name = payload.Name; }
public Task Handle(ProductNameChanged message) { return(null); }