diff --git a/src/LinkAce.NET/Entites/Link.cs b/src/LinkAce.NET/Entites/Link.cs index 25c7aaf..3caf45a 100644 --- a/src/LinkAce.NET/Entites/Link.cs +++ b/src/LinkAce.NET/Entites/Link.cs @@ -43,7 +43,7 @@ public class Link /// /// Gets or sets the tags associated with the link. /// - public string[]? Tags { get; set; } + public Tag[]? Tags { get; set; } /// /// Gets or sets the title of the link. /// diff --git a/src/LinkAce.NET/Entites/Pivot.cs b/src/LinkAce.NET/Entites/Pivot.cs new file mode 100644 index 0000000..29c6803 --- /dev/null +++ b/src/LinkAce.NET/Entites/Pivot.cs @@ -0,0 +1,10 @@ +using JetBrains.Annotations; + +namespace LinkAce.NET.Entites; + +[PublicAPI] +public class Pivot +{ + public int LinkId { get; set; } + public int TagId { get; set; } +} diff --git a/src/LinkAce.NET/Entites/Tag.cs b/src/LinkAce.NET/Entites/Tag.cs new file mode 100644 index 0000000..1cb462d --- /dev/null +++ b/src/LinkAce.NET/Entites/Tag.cs @@ -0,0 +1,21 @@ +using JetBrains.Annotations; + +namespace LinkAce.NET.Entites; + +[PublicAPI] +public class Tag +{ + public DateTime CreatedAt { get; set; } + public DateTime? DeletedAt { get; set; } + public int Id { get; set; } + public bool IsPrivate { get; set; } + public string Name { get; set; } + public Pivot Pivot { get; set; } + public DateTime UpdatedAt { get; set; } + public int UserId { get; set; } + + public static implicit operator Tag(string v) + { + return new Tag { Name = v }; + } +} diff --git a/src/LinkAce.NET/Extensions/StringArrayExtensions.cs b/src/LinkAce.NET/Extensions/StringArrayExtensions.cs new file mode 100644 index 0000000..0da1743 --- /dev/null +++ b/src/LinkAce.NET/Extensions/StringArrayExtensions.cs @@ -0,0 +1,9 @@ +using LinkAce.NET.Entites; + +namespace LinkAce.NET.Extensions; + +public static class StringArrayExtensions +{ + public static Tag[] ToTagArray(this string[] tags) + => tags.Select(t => new Tag { Name = t }).ToArray(); +}