コード例 #1
0
        public ICommandResult handle(CreateProductCommand command)
        {
            //fast fail validations
            command.Validate();

            if (command.Invalid)
            {
                return(new CommandResult("Command invalid", false, command.Notifications));
            }

            var product = new Product();

            product.Name       = command.Name;
            product.Price      = command.Price;
            product.Reviews    = command.Reviews;
            product.Amount     = command.Amount;
            product.AnimalType = command.AnimalType;

            _productRespository.Add(product);

            return(new CommandResult("Product created", true, product));
        }
コード例 #2
0
 public void AddProduct(Product product)
 {
     _iRespository.Add(product);
 }