示例#1
0
        public async Task <ActionResult <Invoices> > DeleteInvoice(int invoiceNumber)
        {
            try
            {
                var invoiceToDelete = await invoicesRepository.GetInvoice(invoiceNumber);

                if (invoiceToDelete == null)
                {
                    return(NotFound($"Invoice with number = {invoiceNumber} cannot be found"));
                }

                return(await invoicesRepository.DeleteInvoice(invoiceNumber));
            }
            catch (Exception)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, "Error deleting invoice"));
            }
        }