new ordering system added
This commit is contained in:
@@ -43,6 +43,24 @@ public class MovieQueryParameters : QueryParameters<MovieResponse>
|
||||
[FromQuery(Name = "budget_to")]
|
||||
public decimal? BudgetTo { get; set; }
|
||||
|
||||
[FromQuery(Name = "rating_average")]
|
||||
public double? RatingAverage { get; set; }
|
||||
|
||||
[FromQuery(Name = "rating_average_from")]
|
||||
public double? RatingAverageFrom { get; set; }
|
||||
|
||||
[FromQuery(Name = "rating_average_to")]
|
||||
public double? RatingAverageTo { get; set; }
|
||||
|
||||
[FromQuery(Name = "rating_count")]
|
||||
public double? RatingCount { get; set; }
|
||||
|
||||
[FromQuery(Name = "rating_count_from")]
|
||||
public double? RatingCountFrom { get; set; }
|
||||
|
||||
[FromQuery(Name = "rating_count_to")]
|
||||
public double? RatingCountTo { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -51,17 +69,21 @@ public class MovieQueryParameters : QueryParameters<MovieResponse>
|
||||
|
||||
public override bool IsMeetingConditions(MovieResponse item) =>
|
||||
(
|
||||
TestString(item.Title, Title)
|
||||
TestStringWithRegex(item.Title, Title)
|
||||
&&
|
||||
TestString(item.OriginalTitle, OriginalTitle)
|
||||
TestStringWithRegex(item.OriginalTitle, OriginalTitle)
|
||||
&&
|
||||
TestString(item.Description, Description)
|
||||
TestStringWithRegex(item.Description, Description)
|
||||
&&
|
||||
TestComparable(item.ReleaseDate, ReleaseDate, ReleaseDateFrom, ReleaseDateTo)
|
||||
&&
|
||||
TestComparable(item.Length, Length, LengthFrom, LengthTo)
|
||||
&&
|
||||
TestComparable(item.Budget, Budget, BudgetFrom, BudgetTo)
|
||||
&&
|
||||
TestComparable(item.Rating.Average, RatingAverage, RatingAverageFrom, RatingAverageTo)
|
||||
&&
|
||||
TestComparable(item.Rating.Count, RatingCount, RatingCountFrom, RatingCountTo)
|
||||
);
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -1,15 +1,35 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Text.Json.Serialization;
|
||||
using WatchIt.Common.Model.Rating;
|
||||
using WatchIt.Common.Query;
|
||||
using WatchIt.Database.Model.Media;
|
||||
|
||||
namespace WatchIt.Common.Model.Movies;
|
||||
|
||||
public class MovieResponse : Movie
|
||||
public class MovieResponse : Movie, IQueryOrderable<MovieResponse>
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
[JsonIgnore]
|
||||
public static IDictionary<string, Func<MovieResponse, IComparable>> OrderableProperties { get; } = new Dictionary<string, Func<MovieResponse, 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 }
|
||||
};
|
||||
|
||||
|
||||
[JsonPropertyName("id")]
|
||||
public long Id { get; set; }
|
||||
|
||||
[JsonPropertyName("rating")]
|
||||
public RatingResponse Rating { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -30,6 +50,7 @@ public class MovieResponse : Movie
|
||||
ReleaseDate = mediaMovie.Media.ReleaseDate;
|
||||
Length = mediaMovie.Media.Length;
|
||||
Budget = mediaMovie.Budget;
|
||||
Rating = new RatingResponse(mediaMovie.Media.RatingMedia);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
Reference in New Issue
Block a user