database page finished
This commit is contained in:
@@ -38,22 +38,22 @@ public class MediaQueryParameters : QueryParameters<MediaResponse>
|
||||
public short? LengthTo { get; set; }
|
||||
|
||||
[FromQuery(Name = "rating_average")]
|
||||
public double? RatingAverage { get; set; }
|
||||
public decimal? RatingAverage { get; set; }
|
||||
|
||||
[FromQuery(Name = "rating_average_from")]
|
||||
public double? RatingAverageFrom { get; set; }
|
||||
public decimal? RatingAverageFrom { get; set; }
|
||||
|
||||
[FromQuery(Name = "rating_average_to")]
|
||||
public double? RatingAverageTo { get; set; }
|
||||
public decimal? RatingAverageTo { get; set; }
|
||||
|
||||
[FromQuery(Name = "rating_count")]
|
||||
public double? RatingCount { get; set; }
|
||||
public long? RatingCount { get; set; }
|
||||
|
||||
[FromQuery(Name = "rating_count_from")]
|
||||
public double? RatingCountFrom { get; set; }
|
||||
public long? RatingCountFrom { get; set; }
|
||||
|
||||
[FromQuery(Name = "rating_count_to")]
|
||||
public double? RatingCountTo { get; set; }
|
||||
public long? RatingCountTo { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -44,22 +44,22 @@ public class MovieQueryParameters : QueryParameters<MovieResponse>
|
||||
public decimal? BudgetTo { get; set; }
|
||||
|
||||
[FromQuery(Name = "rating_average")]
|
||||
public double? RatingAverage { get; set; }
|
||||
public decimal? RatingAverage { get; set; }
|
||||
|
||||
[FromQuery(Name = "rating_average_from")]
|
||||
public double? RatingAverageFrom { get; set; }
|
||||
public decimal? RatingAverageFrom { get; set; }
|
||||
|
||||
[FromQuery(Name = "rating_average_to")]
|
||||
public double? RatingAverageTo { get; set; }
|
||||
public decimal? RatingAverageTo { get; set; }
|
||||
|
||||
[FromQuery(Name = "rating_count")]
|
||||
public double? RatingCount { get; set; }
|
||||
public long? RatingCount { get; set; }
|
||||
|
||||
[FromQuery(Name = "rating_count_from")]
|
||||
public double? RatingCountFrom { get; set; }
|
||||
public long? RatingCountFrom { get; set; }
|
||||
|
||||
[FromQuery(Name = "rating_count_to")]
|
||||
public double? RatingCountTo { get; set; }
|
||||
public long? RatingCountTo { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ public class RatingResponse
|
||||
#region PROPERTIES
|
||||
|
||||
[JsonPropertyName("average")]
|
||||
public required double Average { get; set; }
|
||||
public required decimal Average { get; set; }
|
||||
|
||||
[JsonPropertyName("count")]
|
||||
public required long Count { get; set; }
|
||||
@@ -24,10 +24,10 @@ public class RatingResponse
|
||||
public RatingResponse() {}
|
||||
|
||||
[SetsRequiredMembers]
|
||||
public RatingResponse(IEnumerable<RatingMedia> ratingMedia) : this(ratingMedia.Any() ? ratingMedia.Average(x => x.Rating) : 0, ratingMedia.Count()) {}
|
||||
public RatingResponse(IEnumerable<RatingMedia> ratingMedia) : this(ratingMedia.Any() ? (decimal)ratingMedia.Average(x => x.Rating) : 0, ratingMedia.Count()) {}
|
||||
|
||||
[SetsRequiredMembers]
|
||||
public RatingResponse(double ratingAverage, long ratingCount)
|
||||
public RatingResponse(decimal ratingAverage, long ratingCount)
|
||||
{
|
||||
Average = ratingAverage;
|
||||
Count = ratingCount;
|
||||
|
||||
@@ -38,22 +38,22 @@ public class SeriesQueryParameters : QueryParameters<SeriesResponse>
|
||||
public bool? HasEnded { get; set; }
|
||||
|
||||
[FromQuery(Name = "rating_average")]
|
||||
public double? RatingAverage { get; set; }
|
||||
public decimal? RatingAverage { get; set; }
|
||||
|
||||
[FromQuery(Name = "rating_average_from")]
|
||||
public double? RatingAverageFrom { get; set; }
|
||||
public decimal? RatingAverageFrom { get; set; }
|
||||
|
||||
[FromQuery(Name = "rating_average_to")]
|
||||
public double? RatingAverageTo { get; set; }
|
||||
public decimal? RatingAverageTo { get; set; }
|
||||
|
||||
[FromQuery(Name = "rating_count")]
|
||||
public double? RatingCount { get; set; }
|
||||
public long? RatingCount { get; set; }
|
||||
|
||||
[FromQuery(Name = "rating_count_from")]
|
||||
public double? RatingCountFrom { get; set; }
|
||||
public long? RatingCountFrom { get; set; }
|
||||
|
||||
[FromQuery(Name = "rating_count_to")]
|
||||
public double? RatingCountTo { get; set; }
|
||||
public long? RatingCountTo { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Reflection;
|
||||
using System.Globalization;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Text.RegularExpressions;
|
||||
@@ -38,7 +39,12 @@ public abstract class QueryParameters
|
||||
FromQueryAttribute? attribute = property.GetCustomAttributes<FromQueryAttribute>(true).FirstOrDefault();
|
||||
if (value is not null && attribute is not null)
|
||||
{
|
||||
string query = $"{attribute.Name}={value}";
|
||||
string valueString = (value switch
|
||||
{
|
||||
decimal d => d.ToString(CultureInfo.InvariantCulture),
|
||||
_ => value.ToString()
|
||||
})!;
|
||||
string query = $"{attribute.Name}={valueString}";
|
||||
queries.Add(query);
|
||||
}
|
||||
}
|
||||
@@ -92,7 +98,7 @@ public abstract class QueryParameters
|
||||
(
|
||||
property is not null
|
||||
&&
|
||||
property.CompareTo(from) > 0
|
||||
property.CompareTo(from) >= 0
|
||||
)
|
||||
)
|
||||
&&
|
||||
|
||||
Reference in New Issue
Block a user