2020-03-15 10:51:57 +01:00
|
|
|
using System;
|
2020-06-27 21:55:16 +09:00
|
|
|
using Microsoft.EntityFrameworkCore;
|
2018-04-03 11:50:41 +09:00
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
|
|
|
namespace BTCPayServer.Data
|
|
|
|
{
|
|
|
|
public class AppData
|
|
|
|
{
|
|
|
|
public string Id { get; set; }
|
|
|
|
public string Name { get; set; }
|
2020-12-28 14:57:21 -06:00
|
|
|
public string StoreDataId { get; set; }
|
2018-04-03 11:50:41 +09:00
|
|
|
public string AppType { get; set; }
|
2020-12-28 14:57:21 -06:00
|
|
|
public StoreData StoreData { get; set; }
|
|
|
|
public DateTimeOffset Created { get; set; }
|
2019-02-19 12:48:08 +09:00
|
|
|
public bool TagAllInvoices { get; set; }
|
2018-04-03 11:50:41 +09:00
|
|
|
public string Settings { get; set; }
|
|
|
|
|
2020-12-28 14:57:21 -06:00
|
|
|
internal static void OnModelCreating(ModelBuilder builder)
|
|
|
|
{
|
|
|
|
builder.Entity<AppData>()
|
|
|
|
.HasOne(o => o.StoreData)
|
|
|
|
.WithMany(i => i.Apps).OnDelete(DeleteBehavior.Cascade);
|
|
|
|
builder.Entity<AppData>()
|
|
|
|
.HasOne(a => a.StoreData);
|
|
|
|
}
|
|
|
|
|
|
|
|
// utility methods
|
2018-04-03 11:50:41 +09:00
|
|
|
public T GetSettings<T>() where T : class, new()
|
|
|
|
{
|
2022-06-28 05:03:13 +02:00
|
|
|
return string.IsNullOrEmpty(Settings) ? new T() : JsonConvert.DeserializeObject<T>(Settings);
|
2018-04-03 11:50:41 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
public void SetSettings(object value)
|
|
|
|
{
|
|
|
|
Settings = value == null ? null : JsonConvert.SerializeObject(value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|