public async Task <Response <int> > Handle(DeleteProductByIdCommand command, CancellationToken cancellationToken) { var product = await _productRepository.GetByIdAsync(command.Id); if (product == null) { throw new ApiException($"Product Not Found."); } await _productRepository.DeleteAsync(product); return(new Response <int>(product.Id)); }
public async Task <Response <Guid> > Handle(DeleteProductByIdCommand command, CancellationToken cancellationToken) { var product = await _productRepository.GetByIdAsync(command.Id).ConfigureAwait(false); if (product == null) { throw new ApiException($"Product Not Found."); } await _productRepository.DeleteAsync(product).ConfigureAwait(false); await _unitOfWork.Commit <Guid>(cancellationToken).ConfigureAwait(false); return(new Response <Guid>(product.Id)); }