private void AddNewProduct(AddNewProductCommand c) { var product = new Product { Id = c.Id, Name = c.Name, Price = c.Price, Stock = c.Stock }; try { _inventory.AddNewProduct(product); } catch (Exception e) { var result = CommandResult.Error(e.Message); Sender.Tell(result); return; } var ev = new NewProductAddedToInventory(c.Id, c.Name, c.Price, c.Stock); PersistEventAndSnapshot(ev); Sender.Tell(CommandResult.Success()); }
private void RecoverNewProductAddedToInventory(NewProductAddedToInventory e) { var product = new Product { Id = e.Id, Name = e.Name, Price = e.Price, Stock = e.Stock }; _inventory.AddNewProduct(product); }