public async Task <ActionResult <Invoices> > CreateInvoice([FromBody] Invoices invoice) { try { if (invoice == null) { return(BadRequest()); } var invoiceToCreate = await invoicesRepository.AddInvoice(invoice); return(CreatedAtAction(nameof(GetInvoice), new { invoiceNumber = invoiceToCreate.InvoiceNumber }, invoiceToCreate)); } catch (Exception) { return(StatusCode(StatusCodes.Status500InternalServerError, "Error retrieving creating a new invoice")); } }