Ejemplo n.º 1
0
        public async Task <Response <DeleteProductDto> > Handle(DeleteProductCommand command, CancellationToken cancellationToken)
        {
            var product = await _productRepository.GetByIdAsync(command.Id);

            if (product == null)
            {
                throw new ApiException($"Product Not Found.");
            }
            await _productRepository.RemoveAsync(product);

            var response = _mapper.Map <DeleteProductDto>(product);

            return(new Response <DeleteProductDto>(_mapper.Map <DeleteProductDto>(product), "Product remove successful"));
        }