public static string invoiceData(dynamic log_invoice) { string json = ""; InvoiceModel inv = new InvoiceModel(); dynamic invoice = inv.find(inv, log_invoice.ref_id); if (invoice != null) { dynamic dataObject = new ExpandoObject(); dataObject.id = log_invoice.id; dataObject.key = log_invoice.action; dataObject.trackable_id = invoice.id; dataObject.trackable_type = log_invoice.model; if (log_invoice.action != "delete") { dynamic data = new ExpandoObject(); data.global_id = invoice.id; data.number = invoice.number; data.date = invoice.date; data.invoice_total = invoice.invoice_total; data.discount = invoice.discount; data.vat = invoice.vat; data.till_id = invoice.till_id; data.net_total = invoice.net_total; data.department_id = invoice.department_id; data.customer_id = invoice.customer_id; dataObject.data = data; } json = JsonConvert.SerializeObject(dataObject); } return(json); }