mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2026-01-06 07:34:26 +01:00
[Refactor] Move SQL classes in their own assembly
This commit is contained in:
33
BTCPayServer/Data/HistoricalAddressInvoiceDataExtensions.cs
Normal file
33
BTCPayServer/Data/HistoricalAddressInvoiceDataExtensions.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BTCPayServer.Data
|
||||
{
|
||||
public static class HistoricalAddressInvoiceDataExtensions
|
||||
{
|
||||
#pragma warning disable CS0618
|
||||
public static Payments.PaymentMethodId GetPaymentMethodId(this HistoricalAddressInvoiceData historicalAddressInvoiceData)
|
||||
{
|
||||
return string.IsNullOrEmpty(historicalAddressInvoiceData.CryptoCode) ? new Payments.PaymentMethodId("BTC", Payments.PaymentTypes.BTCLike)
|
||||
: Payments.PaymentMethodId.Parse(historicalAddressInvoiceData.CryptoCode);
|
||||
}
|
||||
public static string GetAddress(this HistoricalAddressInvoiceData historicalAddressInvoiceData)
|
||||
{
|
||||
if (historicalAddressInvoiceData.Address == null)
|
||||
return null;
|
||||
var index = historicalAddressInvoiceData.Address.IndexOf("#", StringComparison.InvariantCulture);
|
||||
if (index == -1)
|
||||
return historicalAddressInvoiceData.Address;
|
||||
return historicalAddressInvoiceData.Address.Substring(0, index);
|
||||
}
|
||||
public static HistoricalAddressInvoiceData SetAddress(this HistoricalAddressInvoiceData historicalAddressInvoiceData, string depositAddress, string cryptoCode)
|
||||
{
|
||||
historicalAddressInvoiceData.Address = depositAddress + "#" + cryptoCode;
|
||||
historicalAddressInvoiceData.CryptoCode = cryptoCode;
|
||||
return historicalAddressInvoiceData;
|
||||
}
|
||||
#pragma warning restore CS0618
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user