Exemple #1
0
        private void When(object @event)
        {
            switch (@event)
            {
            case Events.ProductTypeCreated e:
                Id   = new ProductTypeId(e.Id);
                Name = e.Name;
                break;

            case Events.ProductTypeNameChanged e:
                Name = e.Name;
                break;

            case Events.ProductTypeDeleted e:
                Id   = new ProductTypeId(e.Id);
                Name = e.Name;
                break;
            }
        }
Exemple #2
0
        public static ProductType Create(ProductTypeId id, string name)
        {
            if (id is null)
            {
                throw new ArgumentNullException(nameof(id), "Product type without unique identifier cannot be created.");
            }

            if (string.IsNullOrWhiteSpace(name))
            {
                throw new ArgumentNullException(nameof(name), "Product type without name cannot be created.");
            }

            var productType = new ProductType();

            productType.Apply(new Events.ProductTypeCreated
            {
                Id   = id,
                Name = name
            });

            return(productType);
        }