Esempio n. 1
0
        public async Task DeleteAsync(int id)
        {
            try
            {
                var invoice = await _invoiceDataProvider.GetByInterventionIdAsync(id);

                var message = $"Intervention {id} cannot be deleted because invoice {invoice.Id} is attached to it.";
                _logger.LogError(message);
                throw new InvalidOperationException(message);
            }
            catch (EntityNotFoundException)
            {
                await _documentGenerationManager.DeleteInterventionReportAsync(id);

                await _interventionDataProvider.DeleteByIdAsync(id);
            }
        }