public async Task <OperationResult> DeleteAsync(DeleteProductInput input) { var validationResult = await _validator.ValidateDeleteProduct(input); if (validationResult.IsSuccess) { await _repository.RemoveAsync(input.Id); Task overviewTask = Task.Factory.StartNew(async() => { var overview = await _overviewRepository.GetByProduct(new() { Id = input.Id }); if (overview is not null) { await _overviewRepository.RemoveAsync(overview); } }); Task badgeTask = Task.Factory.StartNew(async() => { var badge = await _badgeRepository.GetByProduct(new() { Id = input.Id }); if (badge is not null) { await _badgeRepository.RemoveAsync(badge); } }); Task imageTask = Task.Factory.StartNew(async() => { var images = await _imageRepository.GetProductImages(new() { Id = input.Id }); if (images is not null) { await _imageRepository.RemoveAsync(new ProductImage { ProductId = input.Id }); } }); Task.WaitAll(overviewTask, badgeTask, imageTask); return(OperationResult.Success()); } else { return(OperationResult.Fail(validationResult)); } }