public override ChangeProductCommand Handle(ChangeProductCommand changeProductCommand) { ProductReference productReference; using (var scope = _productsDao.BeginTransaction()) { productReference = _productsDao.FindById(changeProductCommand.ProductId); productReference.ProductName = changeProductCommand.ProductName; productReference.ProductDescription = changeProductCommand.ProductDescription; productReference.ProductPrice = changeProductCommand.Price; _productsDao.Update(productReference); scope.Commit(); } return(base.Handle(changeProductCommand)); }
public override ChangeProductCommand Handle(ChangeProductCommand changeProductCommand) { Product product; using (var scope = _productsDao.BeginTransaction()) { product = _productsDao.FindById(changeProductCommand.ProductId); product.ProductName = changeProductCommand.ProductName; product.ProductDescription = changeProductCommand.ProductDescription; product.ProductPrice = changeProductCommand.Price; _productsDao.Update(product); scope.Commit(); } if (product != null) { _commandProcessor.Publish(new ProductChangedEvent(product.Id, product.ProductName, product.ProductDescription, product.ProductPrice)); } return(base.Handle(changeProductCommand)); }