new ordering system added
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Text.Json.Serialization;
|
||||
using WatchIt.Database.Model.Rating;
|
||||
|
||||
namespace WatchIt.Common.Model.Rating;
|
||||
|
||||
@@ -7,11 +8,11 @@ public class RatingResponse
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
[JsonPropertyName("rating_average")]
|
||||
public required double RatingAverage { get; set; }
|
||||
[JsonPropertyName("average")]
|
||||
public required double Average { get; set; }
|
||||
|
||||
[JsonPropertyName("rating_count")]
|
||||
public required long RatingCount { get; set; }
|
||||
[JsonPropertyName("count")]
|
||||
public required long Count { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -21,12 +22,15 @@ public class RatingResponse
|
||||
|
||||
[JsonConstructor]
|
||||
public RatingResponse() {}
|
||||
|
||||
|
||||
[SetsRequiredMembers]
|
||||
public RatingResponse(IEnumerable<RatingMedia> ratingMedia) : this(ratingMedia.Any() ? ratingMedia.Average(x => x.Rating) : 0, ratingMedia.Count()) {}
|
||||
|
||||
[SetsRequiredMembers]
|
||||
public RatingResponse(double ratingAverage, long ratingCount)
|
||||
{
|
||||
RatingAverage = ratingAverage;
|
||||
RatingCount = ratingCount;
|
||||
Average = ratingAverage;
|
||||
Count = ratingCount;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
Reference in New Issue
Block a user