manager-service/ManagerService/Data/PushNotification.cs
2026-03-17 09:10:56 +01:00

60 lines
1.3 KiB
C#

using ManagerService.DTOs;
using Microsoft.EntityFrameworkCore;
using System;
using System.ComponentModel.DataAnnotations;
namespace ManagerService.Data
{
[Index(nameof(InstanceId))]
public class PushNotification
{
[Key]
public string Id { get; set; }
[Required]
public string InstanceId { get; set; }
[Required]
public string Title { get; set; }
[Required]
public string Body { get; set; }
[Required]
public string Topic { get; set; }
public PushNotificationStatus Status { get; set; }
public DateTime? ScheduledAt { get; set; }
public DateTime? SentAt { get; set; }
public string? HangfireJobId { get; set; }
public DateTime DateCreation { get; set; } = DateTime.UtcNow;
public PushNotificationDTO ToDTO()
{
return new PushNotificationDTO
{
id = Id,
instanceId = InstanceId,
title = Title,
body = Body,
topic = Topic,
status = Status,
scheduledAt = ScheduledAt,
sentAt = SentAt,
dateCreation = DateCreation
};
}
}
public enum PushNotificationStatus
{
Scheduled,
Sent,
Failed
}
}