public async Task <Result <int> > Handle(CreateProductCommand command, CancellationToken cancellationToken) { var product = _mapper.Map <Domain.Entities.Products.Product>(command); if (await _productRepository.DoesBarCodeExist(product.Barcode)) { return(Result <int> .Failure($"Product with Barcode {product.Barcode} already exists.")); } var result = await _productRepository.AddAsync(product); return(Result <int> .Success(result.Id)); }