public async Task <ProductDto> Handle(CreateProductCommand request, CancellationToken cancellationToken = default)
        {
            var product = new Database.Entities.Product(request.Name, request.Number, request.Quantity, 0);
            await _context.AddAsync(product, cancellationToken);

            var result = await _context.SaveChangesAsync(cancellationToken);

            return(result == 1 ? _productMapper.Map(product) : null);
        }
        public override async Task Execute(CreateProductCommand context)
        {
            var product = new Database.Entities.Product
            {
                Title  = context.Title,
                Prices = context.Prices.Select(price => new Price
                {
                    Color  = price.Color,
                    Size   = price.Size,
                    Amount = price.Amount
                }).ToList(),
                CategoryId = context.CategoryId
            };

            DbContext.Products.Add(product);
            await DbContext.SaveChangesAsync();
        }
        private void UpdateProductPrices(ICollection <UpdateProductCommand.Price> contextPrices, Database.Entities.Product productToUpdate)
        {
            DbContext.RemoveRange(productToUpdate.Prices);

            foreach (var price in contextPrices)
            {
                productToUpdate.Prices.Add(new Price
                {
                    Amount = price.Amount,
                    Color  = price.Color,
                    Size   = price.Size
                });
            }
        }