btcpayserver/BTCPayServer/Models/NotificationViewModels/IndexViewModel.cs

41 lines
1.2 KiB
C#
Raw Normal View History

2020-05-03 17:42:01 -06:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
2020-05-03 17:42:01 -06:00
using System.Text;
using System.Threading.Tasks;
using BTCPayServer.Data;
using BTCPayServer.Events;
using BTCPayServer.Events.Notifications;
using Newtonsoft.Json;
2020-05-03 17:42:01 -06:00
namespace BTCPayServer.Models.NotificationViewModels
2020-05-03 17:42:01 -06:00
{
public class IndexViewModel
{
public List<NotificationViewModel> Items { get; set; }
}
public class NotificationViewModel
{
public string Id { get; set; }
public DateTimeOffset Created { get; set; }
public string Body { get; set; }
public string ActionLink { get; set; }
2020-05-28 22:57:18 -05:00
public bool Seen { get; set; }
}
2020-05-03 17:42:01 -06:00
public static class NotificationViewModelExt
{
public static NotificationViewModel ViewModel(this NotificationData data)
2020-05-03 17:42:01 -06:00
{
var baseType = typeof(NotificationBase);
var typeName = baseType.FullName.Replace(nameof(NotificationBase), data.NotificationType, StringComparison.OrdinalIgnoreCase);
var instance = Activator.CreateInstance(baseType.Assembly.GetType(typeName)) as NotificationBase;
return instance.ToViewModel(data);
2020-05-03 17:42:01 -06:00
}
}
}