new ordering system added

This commit is contained in:
2024-09-29 23:00:32 +02:00
Unverified
parent 69937f13e6
commit 450e4a2f94
19 changed files with 275 additions and 59 deletions

View File

@@ -1,17 +1,36 @@
using System.Diagnostics.CodeAnalysis;
using System.Text.Json.Serialization;
using WatchIt.Common.Model.Rating;
using WatchIt.Common.Query;
namespace WatchIt.Common.Model.Media;
public class MediaResponse : Media
public class MediaResponse : Media, IQueryOrderable<MediaResponse>
{
#region PROPERTIES
[JsonIgnore]
public static IDictionary<string, Func<MediaResponse, IComparable>> OrderableProperties { get; } = new Dictionary<string, Func<MediaResponse, IComparable>>
{
{ "id", x => x.Id },
{ "title", x => x.Title },
{ "original_title", x => x.OriginalTitle },
{ "description", x => x.Description },
{ "release_date", x => x.ReleaseDate },
{ "length", x => x.Length },
{ "rating.average", x => x.Rating.Average },
{ "rating.count", x => x.Rating.Count }
};
[JsonPropertyName("id")]
public long Id { get; set; }
[JsonPropertyName("type")]
public MediaType Type { get; set; }
[JsonPropertyName("rating")]
public RatingResponse Rating { get; set; }
#endregion
@@ -32,6 +51,7 @@ public class MediaResponse : Media
ReleaseDate = media.ReleaseDate;
Length = media.Length;
Type = mediaType;
Rating = new RatingResponse(media.RatingMedia);
}
#endregion