UserPage - Lists of rated movies and tv series added
This commit is contained in:
@@ -60,6 +60,9 @@ public class MovieQueryParameters : QueryParameters<MovieResponse>
|
||||
|
||||
[FromQuery(Name = "rating_count_to")]
|
||||
public long? RatingCountTo { get; set; }
|
||||
|
||||
[FromQuery(Name = "genre")]
|
||||
public IEnumerable<short>? Genres { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -84,6 +87,8 @@ public class MovieQueryParameters : QueryParameters<MovieResponse>
|
||||
TestComparable(item.Rating.Average, RatingAverage, RatingAverageFrom, RatingAverageTo)
|
||||
&&
|
||||
TestComparable(item.Rating.Count, RatingCount, RatingCountFrom, RatingCountTo)
|
||||
&&
|
||||
TestContains(item.Genres.Select(x => x.Id), Genres)
|
||||
);
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using WatchIt.Common.Query;
|
||||
|
||||
namespace WatchIt.Common.Model.Movies;
|
||||
|
||||
public class MovieRatedQueryParameters : QueryParameters<MovieRatedResponse>
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
[FromQuery(Name = "title")]
|
||||
public string? Title { get; set; }
|
||||
|
||||
[FromQuery(Name = "original_title")]
|
||||
public string? OriginalTitle { get; set; }
|
||||
|
||||
[FromQuery(Name = "description")]
|
||||
public string? Description { get; set; }
|
||||
|
||||
[FromQuery(Name = "release_date")]
|
||||
public DateOnly? ReleaseDate { get; set; }
|
||||
|
||||
[FromQuery(Name = "release_date_from")]
|
||||
public DateOnly? ReleaseDateFrom { get; set; }
|
||||
|
||||
[FromQuery(Name = "release_date_to")]
|
||||
public DateOnly? ReleaseDateTo { get; set; }
|
||||
|
||||
[FromQuery(Name = "length")]
|
||||
public short? Length { get; set; }
|
||||
|
||||
[FromQuery(Name = "length_from")]
|
||||
public short? LengthFrom { get; set; }
|
||||
|
||||
[FromQuery(Name = "length_to")]
|
||||
public short? LengthTo { get; set; }
|
||||
|
||||
[FromQuery(Name = "budget")]
|
||||
public decimal? Budget { get; set; }
|
||||
|
||||
[FromQuery(Name = "budget_from")]
|
||||
public decimal? BudgetFrom { get; set; }
|
||||
|
||||
[FromQuery(Name = "budget_to")]
|
||||
public decimal? BudgetTo { get; set; }
|
||||
|
||||
[FromQuery(Name = "rating_average")]
|
||||
public decimal? RatingAverage { get; set; }
|
||||
|
||||
[FromQuery(Name = "rating_average_from")]
|
||||
public decimal? RatingAverageFrom { get; set; }
|
||||
|
||||
[FromQuery(Name = "rating_average_to")]
|
||||
public decimal? RatingAverageTo { get; set; }
|
||||
|
||||
[FromQuery(Name = "rating_count")]
|
||||
public long? RatingCount { get; set; }
|
||||
|
||||
[FromQuery(Name = "rating_count_from")]
|
||||
public long? RatingCountFrom { get; set; }
|
||||
|
||||
[FromQuery(Name = "rating_count_to")]
|
||||
public long? RatingCountTo { get; set; }
|
||||
|
||||
[FromQuery(Name = "genre")]
|
||||
public IEnumerable<short>? Genres { get; set; }
|
||||
|
||||
[FromQuery(Name = "user_rating")]
|
||||
public decimal? UserRating { get; set; }
|
||||
|
||||
[FromQuery(Name = "user_rating_from")]
|
||||
public decimal? UserRatingFrom { get; set; }
|
||||
|
||||
[FromQuery(Name = "user_rating_to")]
|
||||
public decimal? UserRatingTo { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PRIVATE METHODS
|
||||
|
||||
protected override bool IsMeetingConditions(MovieRatedResponse item) =>
|
||||
(
|
||||
TestStringWithRegex(item.Title, Title)
|
||||
&&
|
||||
TestStringWithRegex(item.OriginalTitle, OriginalTitle)
|
||||
&&
|
||||
TestStringWithRegex(item.Description, Description)
|
||||
&&
|
||||
TestComparable(item.ReleaseDate, ReleaseDate, ReleaseDateFrom, ReleaseDateTo)
|
||||
&&
|
||||
TestComparable(item.Length, Length, LengthFrom, LengthTo)
|
||||
&&
|
||||
TestComparable(item.Rating.Average, RatingAverage, RatingAverageFrom, RatingAverageTo)
|
||||
&&
|
||||
TestComparable(item.Rating.Count, RatingCount, RatingCountFrom, RatingCountTo)
|
||||
&&
|
||||
TestContains(Genres, item.Genres.Select(x => x.Id))
|
||||
&&
|
||||
TestComparable((decimal)item.UserRating, UserRating, UserRatingFrom, UserRatingTo)
|
||||
);
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Text.Json.Serialization;
|
||||
using WatchIt.Common.Model.Genres;
|
||||
using WatchIt.Common.Model.Rating;
|
||||
using WatchIt.Common.Query;
|
||||
using WatchIt.Database.Model.Media;
|
||||
using WatchIt.Database.Model.Rating;
|
||||
|
||||
namespace WatchIt.Common.Model.Movies;
|
||||
|
||||
public class MovieRatedResponse : MovieResponse, IQueryOrderable<MovieRatedResponse>
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
[JsonIgnore]
|
||||
public static IDictionary<string, Func<MovieRatedResponse, IComparable>> OrderableProperties { get; } = new Dictionary<string, Func<MovieRatedResponse, 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 },
|
||||
{ "budget", x => x.Budget },
|
||||
{ "rating.average", x => x.Rating.Average },
|
||||
{ "rating.count", x => x.Rating.Count },
|
||||
{ "user_rating", x => x.UserRating }
|
||||
};
|
||||
|
||||
[JsonPropertyName("user_rating")]
|
||||
public short UserRating { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region CONSTRUCTORS
|
||||
|
||||
[JsonConstructor]
|
||||
public MovieRatedResponse() { }
|
||||
|
||||
[SetsRequiredMembers]
|
||||
public MovieRatedResponse(MediaMovie mediaMovie, RatingMedia response)
|
||||
{
|
||||
Id = mediaMovie.Media.Id;
|
||||
Title = mediaMovie.Media.Title;
|
||||
OriginalTitle = mediaMovie.Media.OriginalTitle;
|
||||
Description = mediaMovie.Media.Description;
|
||||
ReleaseDate = mediaMovie.Media.ReleaseDate;
|
||||
Length = mediaMovie.Media.Length;
|
||||
Budget = mediaMovie.Budget;
|
||||
Rating = RatingResponse.Create(mediaMovie.Media.RatingMedia);
|
||||
Genres = mediaMovie.Media.Genres.Select(x => new GenreResponse(x)).ToList();
|
||||
UserRating = response.Rating;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Text.Json.Serialization;
|
||||
using WatchIt.Common.Model.Genres;
|
||||
using WatchIt.Common.Model.Rating;
|
||||
using WatchIt.Common.Query;
|
||||
using WatchIt.Database.Model.Media;
|
||||
@@ -30,6 +31,9 @@ public class MovieResponse : Movie, IQueryOrderable<MovieResponse>
|
||||
|
||||
[JsonPropertyName("rating")]
|
||||
public RatingResponse Rating { get; set; }
|
||||
|
||||
[JsonPropertyName("genres")]
|
||||
public IEnumerable<GenreResponse> Genres { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -51,6 +55,7 @@ public class MovieResponse : Movie, IQueryOrderable<MovieResponse>
|
||||
Length = mediaMovie.Media.Length;
|
||||
Budget = mediaMovie.Budget;
|
||||
Rating = RatingResponse.Create(mediaMovie.Media.RatingMedia);
|
||||
Genres = mediaMovie.Media.Genres.Select(x => new GenreResponse(x)).ToList();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
Reference in New Issue
Block a user