Exemplo n.º 1
0
        public async Task <string> Handle(ProductSpecCreateCommand request, CancellationToken cancellationToken)
        {
            var spec = new ProductSpec(request.Name, request.Description, request.ProductId, identityService.GetOrganizationId(), identityService.GetUserId());

            spec.UpdatePriceInfo(request.Price, request.PartnerPrice, request.PurchasePrice);
            await productSpecRepository.AddAsync(spec);

            return(spec.Id);
        }
        public async Task Handle(ProductCreatedEvent notification, CancellationToken cancellationToken)
        {
            var spec = new ProductSpec(notification.Name, string.Empty, notification.Id, notification.OrganizationId, notification.Creator, notification.SourcedStaticMeshId);
            await productSpecRepository.AddAsync(spec);

            var product = await productRepository.FindAsync(notification.Id);

            product.SetDefaultProductSpec(spec);
            await productRepository.UpdateAsync(product);
        }