From b49b11828c1370efd5c59f70460c2f7509d39a69 Mon Sep 17 00:00:00 2001 From: Glax Date: Fri, 9 May 2025 12:22:32 +0200 Subject: [PATCH] Add ToString Overriddes --- API/Schema/Author.cs | 5 +++++ API/Schema/Jobs/Job.cs | 5 +++++ API/Schema/Link.cs | 5 +++++ API/Schema/LocalLibrary.cs | 5 +++++ API/Schema/MangaAltTitle.cs | 5 +++++ API/Schema/MangaTag.cs | 5 +++++ API/Schema/Notification.cs | 40 +++++++++++++++++++++++++++++-------- 7 files changed, 62 insertions(+), 8 deletions(-) diff --git a/API/Schema/Author.cs b/API/Schema/Author.cs index 37685c3..b3149af 100644 --- a/API/Schema/Author.cs +++ b/API/Schema/Author.cs @@ -12,4 +12,9 @@ public class Author(string authorName) [StringLength(128)] [Required] public string AuthorName { get; init; } = authorName; + + public override string ToString() + { + return $"{AuthorId} {AuthorName}"; + } } \ No newline at end of file diff --git a/API/Schema/Jobs/Job.cs b/API/Schema/Jobs/Job.cs index 07fb42a..c722b27 100644 --- a/API/Schema/Jobs/Job.cs +++ b/API/Schema/Jobs/Job.cs @@ -84,4 +84,9 @@ public abstract class Job } protected abstract IEnumerable RunInternal(PgsqlContext context); + + public override string ToString() + { + return $"{JobId}"; + } } \ No newline at end of file diff --git a/API/Schema/Link.cs b/API/Schema/Link.cs index e20ac8b..e797a1e 100644 --- a/API/Schema/Link.cs +++ b/API/Schema/Link.cs @@ -16,4 +16,9 @@ public class Link(string linkProvider, string linkUrl) [Required] [Url] public string LinkUrl { get; init; } = linkUrl; + + public override string ToString() + { + return $"{LinkId} {LinkProvider} {LinkUrl}"; + } } \ No newline at end of file diff --git a/API/Schema/LocalLibrary.cs b/API/Schema/LocalLibrary.cs index 5ad7597..274b763 100644 --- a/API/Schema/LocalLibrary.cs +++ b/API/Schema/LocalLibrary.cs @@ -14,4 +14,9 @@ public class LocalLibrary(string basePath, string libraryName) [StringLength(512)] [Required] public string LibraryName { get; internal set; } = libraryName; + + public override string ToString() + { + return $"{LocalLibraryId} {LibraryName} - {BasePath}"; + } } \ No newline at end of file diff --git a/API/Schema/MangaAltTitle.cs b/API/Schema/MangaAltTitle.cs index 86248cf..23e5854 100644 --- a/API/Schema/MangaAltTitle.cs +++ b/API/Schema/MangaAltTitle.cs @@ -15,4 +15,9 @@ public class MangaAltTitle(string language, string title) [StringLength(256)] [Required] public string Title { get; set; } = title; + + public override string ToString() + { + return $"{AltTitleId} {Language} {Title}"; + } } \ No newline at end of file diff --git a/API/Schema/MangaTag.cs b/API/Schema/MangaTag.cs index 2967d25..aa2e94b 100644 --- a/API/Schema/MangaTag.cs +++ b/API/Schema/MangaTag.cs @@ -9,4 +9,9 @@ public class MangaTag(string tag) [StringLength(64)] [Required] public string Tag { get; init; } = tag; + + public override string ToString() + { + return $"{Tag}"; + } } \ No newline at end of file diff --git a/API/Schema/Notification.cs b/API/Schema/Notification.cs index 46dfb67..e58fe16 100644 --- a/API/Schema/Notification.cs +++ b/API/Schema/Notification.cs @@ -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; + } + + /// + /// EF ONLY!!! + /// + 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}"; + } } \ No newline at end of file