2024-09-19 13:36:01 +02:00
|
|
|
|
using System.Diagnostics.CodeAnalysis;
|
|
|
|
|
|
using System.Text.Json.Serialization;
|
2024-09-29 23:00:32 +02:00
|
|
|
|
using WatchIt.Common.Model.Rating;
|
|
|
|
|
|
using WatchIt.Common.Query;
|
2024-09-19 13:36:01 +02:00
|
|
|
|
|
|
|
|
|
|
namespace WatchIt.Common.Model.Media;
|
|
|
|
|
|
|
2024-09-29 23:00:32 +02:00
|
|
|
|
public class MediaResponse : Media, IQueryOrderable<MediaResponse>
|
2024-09-19 13:36:01 +02:00
|
|
|
|
{
|
|
|
|
|
|
#region PROPERTIES
|
|
|
|
|
|
|
2024-09-29 23:00:32 +02:00
|
|
|
|
[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 }
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-09-22 00:37:26 +02:00
|
|
|
|
[JsonPropertyName("id")]
|
2024-09-19 13:36:01 +02:00
|
|
|
|
public long Id { get; set; }
|
|
|
|
|
|
|
2024-09-22 00:37:26 +02:00
|
|
|
|
[JsonPropertyName("type")]
|
2024-09-19 13:36:01 +02:00
|
|
|
|
public MediaType Type { get; set; }
|
2024-09-29 23:00:32 +02:00
|
|
|
|
|
|
|
|
|
|
[JsonPropertyName("rating")]
|
|
|
|
|
|
public RatingResponse Rating { get; set; }
|
2024-09-19 13:36:01 +02:00
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region CONSTRUCTORS
|
|
|
|
|
|
|
|
|
|
|
|
[JsonConstructor]
|
|
|
|
|
|
public MediaResponse() {}
|
|
|
|
|
|
|
|
|
|
|
|
[SetsRequiredMembers]
|
|
|
|
|
|
public MediaResponse(Database.Model.Media.Media media, MediaType mediaType)
|
|
|
|
|
|
{
|
|
|
|
|
|
Id = media.Id;
|
|
|
|
|
|
Title = media.Title;
|
|
|
|
|
|
OriginalTitle = media.OriginalTitle;
|
|
|
|
|
|
Description = media.Description;
|
|
|
|
|
|
ReleaseDate = media.ReleaseDate;
|
|
|
|
|
|
Length = media.Length;
|
|
|
|
|
|
Type = mediaType;
|
2024-10-02 16:09:11 +02:00
|
|
|
|
Rating = RatingResponse.Create(media.RatingMedia);
|
2024-09-19 13:36:01 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
}
|