public Invoice AddInvoice(Invoice invoice) { //var nextId = invoices.Count == 0 ? 1 : invoices.Max(i => i.Id); //var persistedInvoice = new Invoice(nextId) { // Ammount = invoice.Ammount, // DueDate = invoice.DueDate, // InvoiceNumber = invoice.InvoiceNumber, // InvoiceDate = invoice.InvoiceDate, // Quantity = invoice.Quantity, // Status = invoice.Status //}; //invoices.Add(persistedInvoice); var savedInvoice = ledgerRepository.AddInvoice(invoice); return(savedInvoice); }