mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-18 06:24:24 +01:00
* NotifyEmail field on Invoice, sending email when triggered * Styling invoices page * Exporting Invoices in JSON * Recoding based on feedback * Fixing image breaking responsive layout on mobile * Reducing amount of data sent in email notification * Turning bundling on by default
43 lines
1.2 KiB
C#
43 lines
1.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using BTCPayServer.Services.Invoices;
|
|
using Newtonsoft.Json;
|
|
|
|
namespace BTCPayServer.Models.InvoicingModels
|
|
{
|
|
public class ExportInvoicesModel
|
|
{
|
|
public InvoiceEntity[] Invoices { get; set; }
|
|
public string Format { get; set; }
|
|
|
|
public string Process()
|
|
{
|
|
if (String.Equals(Format, "json", StringComparison.OrdinalIgnoreCase))
|
|
return processJson();
|
|
else
|
|
throw new Exception("Export format not supported");
|
|
}
|
|
|
|
private string processJson()
|
|
{
|
|
foreach (var i in Invoices)
|
|
{
|
|
// removing error causing complex circular dependencies
|
|
i.Payments?.ForEach(a =>
|
|
{
|
|
a.Output = null;
|
|
a.Outpoint = null;
|
|
});
|
|
}
|
|
|
|
var serializerSett = new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore };
|
|
var json = JsonConvert.SerializeObject(new { Invoices }, Formatting.Indented, serializerSett);
|
|
|
|
return json;
|
|
}
|
|
}
|
|
}
|