public static IEnumerable <QuickBookInvoice> MergeInvoices(IEnumerable <Invoice> invoices) { var lst = new List <QuickBookInvoice>(); var customers = invoices.Select((x) => x.CustomerName).Distinct(); foreach (var customer in customers) { var qbInv = new QuickBookInvoice() { CustomerName = customer }; foreach (var inv in invoices.Where((x) => x.CustomerName == customer)) { var itm = new QuickBookInvoiceItem() { NewspaperNumber = inv.NewspaperNumber, Price = inv.Price }; qbInv.Items.Add(itm); } lst.Add(qbInv); } return(lst); }
public QuickBookCreateInvoice(QuickBookInvoice invoice) { Invoice = invoice; }