public dynamic RetrieveProduct(int productId)
        {
            var product      = _productsDao.FindById(productId);
            var productModel = new ProductModel(product, _hostName);

            return(productModel);
        }
Ejemplo n.º 2
0
        public override RemoveProductCommand Handle(RemoveProductCommand removeProductCommand)
        {
            ProductReference productReference;

            using (var scope = _productsDao.BeginTransaction())
            {
                productReference = _productsDao.FindById(removeProductCommand.ProductId);
                _productsDao.Delete(removeProductCommand.ProductId);

                scope.Commit();
            }

            return(base.Handle(removeProductCommand));
        }
        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));
        }
Ejemplo n.º 4
0
        public override RemoveProductCommand Handle(RemoveProductCommand removeProductCommand)
        {
            Product product;

            using (var scope = _productsDao.BeginTransaction())
            {
                product = _productsDao.FindById(removeProductCommand.ProductId);
                _productsDao.Delete(removeProductCommand.ProductId);
            }

            if (product != null)
            {
                _commandProcessor.Publish(new ProductRemovedEvent(product.Id, product.ProductName, product.ProductDescription, product.ProductPrice));
            }

            return(base.Handle(removeProductCommand));
        }
        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));
        }