Exemplo n.º 1
0
        public ICommandResult handle(UpdateProductCommand command)
        {
            var inventory = new Inventory();

            foreach (var _warehouse in command.inventory.warehouses)
            {
                var warehouse = new Warehouse(_warehouse.locality,
                                              _warehouse.quantity,
                                              _warehouse.type == "ECOMMERCE" ? WarehouseType.eCommerce : WarehouseType.physicalStore);
                inventory.add(warehouse);
            }

            var product = new Product(command.sku, command.name, inventory);

            command.valid();
            AddNotifications(command.Notifications);

            if (!Invalid)
            {
                productRepository.update(product);
                return(new CommandResult(true, "Produto Regitrado com êxito", command));
            }
            else
            {
                return(new CommandResult(false, "Por favor, corrija os campos abaixo", Notifications));
            }
        }