Add ToString Overriddes

This commit is contained in:
2025-05-09 12:22:32 +02:00
parent 2d69b30e83
commit b49b11828c
7 changed files with 62 additions and 8 deletions

View File

@@ -4,25 +4,49 @@ using Microsoft.EntityFrameworkCore;
namespace API.Schema;
[PrimaryKey("NotificationId")]
public class Notification(string title, string message = "", NotificationUrgency urgency = NotificationUrgency.Normal, DateTime? date = null)
public class Notification
{
[StringLength(64)]
[Required]
public string NotificationId { get; init; } = TokenGen.CreateToken("Notification");
public string NotificationId { get; init; }
[Required]
public NotificationUrgency Urgency { get; init; } = urgency;
public NotificationUrgency Urgency { get; init; }
[StringLength(128)]
[Required]
public string Title { get; init; } = title;
public string Title { get; init; }
[StringLength(512)]
[Required]
public string Message { get; init; } = message;
public string Message { get; init; }
[Required]
public DateTime Date { get; init; } = date ?? DateTime.UtcNow;
public Notification() : this("") { }
public DateTime Date { get; init; }
public Notification(string title, string message = "", NotificationUrgency urgency = NotificationUrgency.Normal, DateTime? date = null)
{
this.NotificationId = TokenGen.CreateToken("Notification");
this.Title = title;
this.Message = message;
this.Urgency = urgency;
this.Date = date ?? DateTime.UtcNow;
}
/// <summary>
/// EF ONLY!!!
/// </summary>
public Notification(string notificationId, string title, string message, NotificationUrgency urgency, DateTime date)
{
this.NotificationId = notificationId;
this.Title = title;
this.Message = message;
this.Urgency = urgency;
this.Date = date;
}
public override string ToString()
{
return $"{NotificationId} {Urgency} {Title}";
}
}