diff --git a/Kyoo.Common/Models/LibraryItem.cs b/Kyoo.Common/Models/LibraryItem.cs
index 7d48dd75..4df07770 100644
--- a/Kyoo.Common/Models/LibraryItem.cs
+++ b/Kyoo.Common/Models/LibraryItem.cs
@@ -1,6 +1,5 @@
using System;
using System.Linq.Expressions;
-using JetBrains.Annotations;
using Kyoo.Models.Attributes;
namespace Kyoo.Models
@@ -59,12 +58,23 @@ namespace Kyoo.Models
/// By default, the http path for this poster is returned from the public API.
/// This can be disabled using the internal query flag.
///
- [SerializeAs("{HOST}/api/{_type}/{Slug}/poster")] public string Poster { get; set; }
- [UsedImplicitly] private string _type => Type == ItemType.Collection ? "collection" : "show";
+ [SerializeAs("{HOST}/api/{Type}/{Slug}/poster")] public string Poster { get; set; }
+
+ ///
+ /// The type of this item (ether a collection, a show or a movie).
+ ///
public ItemType Type { get; set; }
+
+ ///
+ /// Create a new, empty .
+ ///
public LibraryItem() {}
+ ///
+ /// Create a from a show.
+ ///
+ /// The show that this library item should represent.
public LibraryItem(Show show)
{
ID = show.ID;
@@ -78,6 +88,10 @@ namespace Kyoo.Models
Type = show.IsMovie ? ItemType.Movie : ItemType.Show;
}
+ ///
+ /// Create a from a collection
+ ///
+ /// The collection that this library item should represent.
public LibraryItem(Collection collection)
{
ID = -collection.ID;
@@ -91,6 +105,9 @@ namespace Kyoo.Models
Type = ItemType.Collection;
}
+ ///
+ /// An expression to create a representing a show.
+ ///
public static Expression> FromShow => x => new LibraryItem
{
ID = x.ID,
@@ -104,6 +121,9 @@ namespace Kyoo.Models
Type = x.IsMovie ? ItemType.Movie : ItemType.Show
};
+ ///
+ /// An expression to create a representing a collection.
+ ///
public static Expression> FromCollection => x => new LibraryItem
{
ID = -x.ID,
diff --git a/Kyoo.Common/Models/Link.cs b/Kyoo.Common/Models/Link.cs
index 41758b52..6d815af9 100644
--- a/Kyoo.Common/Models/Link.cs
+++ b/Kyoo.Common/Models/Link.cs
@@ -3,30 +3,62 @@ using System.Linq.Expressions;
namespace Kyoo.Models
{
+ ///
+ /// A class representing a link between two resources.
+ ///
+ ///
+ /// Links should only be used on the data layer and not on other application code.
+ ///
public class Link
{
+ ///
+ /// The ID of the first item of the link.
+ /// The first item of the link should be the one to own the link.
+ ///
public int FirstID { get; set; }
+
+ ///
+ /// The ID of the second item of this link
+ /// The second item of the link should be the owned resource.
+ ///
public int SecondID { get; set; }
+ ///
+ /// Create a new typeless .
+ ///
public Link() {}
+ ///
+ /// Create a new typeless with two IDs.
+ ///
+ /// The ID of the first resource
+ /// The ID of the second resource
public Link(int firstID, int secondID)
{
FirstID = firstID;
SecondID = secondID;
}
+ ///
+ /// Create a new typeless between two resources.
+ ///
+ /// The first resource
+ /// The second resource
public Link(IResource first, IResource second)
{
FirstID = first.ID;
SecondID = second.ID;
}
- public static Link Create(IResource first, IResource second)
- {
- return new(first, second);
- }
-
+ ///
+ /// Create a new typed link between two resources.
+ /// This method can be used instead of the constructor to make use of generic parameters deduction.
+ ///
+ /// The first resource
+ /// The second resource
+ /// The type of the first resource
+ /// The type of the second resource
+ /// A newly created typed link with both resources
public static Link Create(T first, T2 second)
where T : class, IResource
where T2 : class, IResource
@@ -34,6 +66,16 @@ namespace Kyoo.Models
return new(first, second);
}
+ ///
+ /// Create a new typed link between two resources without storing references to resources.
+ /// This is the same as but this method does not set
+ /// and fields. Only IDs are stored and not references.
+ ///
+ /// The first resource
+ /// The second resource
+ /// The type of the first resource
+ /// The type of the second resource
+ /// A newly created typed link with both resources
public static Link UCreate(T first, T2 second)
where T : class, IResource
where T2 : class, IResource
@@ -41,6 +83,9 @@ namespace Kyoo.Models
return new(first, second, true);
}
+ ///
+ /// The expression to retrieve the unique ID of a Link. This is an aggregate of the two resources IDs.
+ ///
public static Expression> PrimaryKey
{
get
@@ -50,16 +95,41 @@ namespace Kyoo.Models
}
}
+ ///
+ /// A strongly typed link between two resources.
+ ///
+ /// The type of the first resource
+ /// The type of the second resource
public class Link : Link
where T1 : class, IResource
where T2 : class, IResource
{
+ ///
+ /// A reference of the first resource.
+ ///
public T1 First { get; set; }
+
+ ///
+ /// A reference to the second resource.
+ ///
public T2 Second { get; set; }
+ ///
+ /// Create a new, empty, typed .
+ ///
public Link() {}
+
+ ///
+ /// Create a new typed link with two resources.
+ ///
+ /// The first resource
+ /// The second resource
+ ///
+ /// True if no reference to resources should be kept, false otherwise.
+ /// The default is false (references are kept).
+ ///
public Link(T1 first, T2 second, bool privateItems = false)
: base(first, second)
{
@@ -69,10 +139,18 @@ namespace Kyoo.Models
Second = second;
}
+ ///
+ /// Create a new typed link with IDs only.
+ ///
+ /// The ID of the first resource
+ /// The ID of the second resource
public Link(int firstID, int secondID)
: base(firstID, secondID)
{ }
+ ///
+ /// The expression to retrieve the unique ID of a typed Link. This is an aggregate of the two resources IDs.
+ ///
public new static Expression, object>> PrimaryKey
{
get
diff --git a/Kyoo.Common/Models/MetadataID.cs b/Kyoo.Common/Models/MetadataID.cs
index 400d65da..7621830c 100644
--- a/Kyoo.Common/Models/MetadataID.cs
+++ b/Kyoo.Common/Models/MetadataID.cs
@@ -2,9 +2,16 @@ using Kyoo.Models.Attributes;
namespace Kyoo.Models
{
+ ///
+ /// ID and link of an item on an external provider.
+ ///
public class MetadataID
{
+ ///
+ /// The unique ID of this metadata. This is the equivalent of .
+ ///
[SerializeIgnore] public int ID { get; set; }
+
[SerializeIgnore] public int ProviderID { get; set; }
public Provider Provider {get; set; }
diff --git a/Kyoo/Views/ShowApi.cs b/Kyoo/Views/ShowApi.cs
index 4e121d75..966aad05 100644
--- a/Kyoo/Views/ShowApi.cs
+++ b/Kyoo/Views/ShowApi.cs
@@ -16,6 +16,8 @@ namespace Kyoo.Api
{
[Route("api/show")]
[Route("api/shows")]
+ [Route("api/movie")]
+ [Route("api/movies")]
[ApiController]
[PartialPermission(nameof(ShowApi))]
public class ShowApi : CrudApi