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

                if (invoice.BookingDate != null)
                {
                    var message = $"Invoice {id} cannot be deleted because it has already been transferred to the accounting system.";
                    _logger.LogError(message);
                    throw new InvalidOperationException(message);
                }

                await _documentGenerationManager.DeleteInvoiceDocumentAsync(id);

                await _documentGenerationManager.DeleteCertificateTemplateForInvoiceAsync(id);

                await _documentGenerationManager.DeleteCertificateForInvoiceAsync(id);

                await _invoiceDataProvider.DeleteByIdAsync(id);
            }
            catch (EntityNotFoundException)
            {
                // Invoice not found. Nothing should happen.
            }
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> DeleteCertificateAsync(int invoiceId)
        {
            await _documentGenerationManager.DeleteCertificateForInvoiceAsync(invoiceId);

            return(NoContent());
        }