Add ToString Overriddes

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

View File

@ -12,4 +12,9 @@ public class Author(string authorName)
[StringLength(128)] [StringLength(128)]
[Required] [Required]
public string AuthorName { get; init; } = authorName; public string AuthorName { get; init; } = authorName;
public override string ToString()
{
return $"{AuthorId} {AuthorName}";
}
} }

View File

@ -84,4 +84,9 @@ public abstract class Job
} }
protected abstract IEnumerable<Job> RunInternal(PgsqlContext context); protected abstract IEnumerable<Job> RunInternal(PgsqlContext context);
public override string ToString()
{
return $"{JobId}";
}
} }

View File

@ -16,4 +16,9 @@ public class Link(string linkProvider, string linkUrl)
[Required] [Required]
[Url] [Url]
public string LinkUrl { get; init; } = linkUrl; public string LinkUrl { get; init; } = linkUrl;
public override string ToString()
{
return $"{LinkId} {LinkProvider} {LinkUrl}";
}
} }

View File

@ -14,4 +14,9 @@ public class LocalLibrary(string basePath, string libraryName)
[StringLength(512)] [StringLength(512)]
[Required] [Required]
public string LibraryName { get; internal set; } = libraryName; public string LibraryName { get; internal set; } = libraryName;
public override string ToString()
{
return $"{LocalLibraryId} {LibraryName} - {BasePath}";
}
} }

View File

@ -15,4 +15,9 @@ public class MangaAltTitle(string language, string title)
[StringLength(256)] [StringLength(256)]
[Required] [Required]
public string Title { get; set; } = title; public string Title { get; set; } = title;
public override string ToString()
{
return $"{AltTitleId} {Language} {Title}";
}
} }

View File

@ -9,4 +9,9 @@ public class MangaTag(string tag)
[StringLength(64)] [StringLength(64)]
[Required] [Required]
public string Tag { get; init; } = tag; public string Tag { get; init; } = tag;
public override string ToString()
{
return $"{Tag}";
}
} }

View File

@ -4,25 +4,49 @@ using Microsoft.EntityFrameworkCore;
namespace API.Schema; namespace API.Schema;
[PrimaryKey("NotificationId")] [PrimaryKey("NotificationId")]
public class Notification(string title, string message = "", NotificationUrgency urgency = NotificationUrgency.Normal, DateTime? date = null) public class Notification
{ {
[StringLength(64)] [StringLength(64)]
[Required] [Required]
public string NotificationId { get; init; } = TokenGen.CreateToken("Notification"); public string NotificationId { get; init; }
[Required] [Required]
public NotificationUrgency Urgency { get; init; } = urgency; public NotificationUrgency Urgency { get; init; }
[StringLength(128)] [StringLength(128)]
[Required] [Required]
public string Title { get; init; } = title; public string Title { get; init; }
[StringLength(512)] [StringLength(512)]
[Required] [Required]
public string Message { get; init; } = message; public string Message { get; init; }
[Required] [Required]
public DateTime Date { get; init; } = date ?? DateTime.UtcNow; public DateTime Date { get; init; }
public Notification() : this("") { } 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}";
}
} }