public async Task DeleteAsync(int id) { try { var order = await _orderDataProvider.GetByOfferIdAsync(id); var message = $"Offer {id} cannot be deleted because order {order.Id} is attached to it."; _logger.LogError(message); throw new InvalidOperationException(message); } catch (EntityNotFoundException) { await _documentGenerationManager.DeleteOfferDocumentAsync(id); await _offerDataProvider.DeleteByIdAsync(id); } }