Files
WatchIt/WatchIt.Common/WatchIt.Common.Model/Series/SeriesQueryParameters.cs

84 lines
2.3 KiB
C#
Raw Normal View History

2024-09-21 23:42:10 +02:00
using Microsoft.AspNetCore.Mvc;
using WatchIt.Common.Query;
namespace WatchIt.Common.Model.Series;
public class SeriesQueryParameters : QueryParameters<SeriesResponse>
{
#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 = "has_ended")]
public bool? HasEnded { get; set; }
2024-09-29 23:00:32 +02:00
[FromQuery(Name = "rating_average")]
2024-10-02 01:08:52 +02:00
public decimal? RatingAverage { get; set; }
2024-09-29 23:00:32 +02:00
[FromQuery(Name = "rating_average_from")]
2024-10-02 01:08:52 +02:00
public decimal? RatingAverageFrom { get; set; }
2024-09-29 23:00:32 +02:00
[FromQuery(Name = "rating_average_to")]
2024-10-02 01:08:52 +02:00
public decimal? RatingAverageTo { get; set; }
2024-09-29 23:00:32 +02:00
[FromQuery(Name = "rating_count")]
2024-10-02 01:08:52 +02:00
public long? RatingCount { get; set; }
2024-09-29 23:00:32 +02:00
[FromQuery(Name = "rating_count_from")]
2024-10-02 01:08:52 +02:00
public long? RatingCountFrom { get; set; }
2024-09-29 23:00:32 +02:00
[FromQuery(Name = "rating_count_to")]
2024-10-02 01:08:52 +02:00
public long? RatingCountTo { get; set; }
2024-09-29 23:00:32 +02:00
2024-09-21 23:42:10 +02:00
#endregion
2024-10-02 16:09:11 +02:00
#region PRIVATE METHODS
2024-09-21 23:42:10 +02:00
2024-10-02 16:09:11 +02:00
protected override bool IsMeetingConditions(SeriesResponse item) =>
2024-09-21 23:42:10 +02:00
(
2024-09-29 23:00:32 +02:00
TestStringWithRegex(item.Title, Title)
2024-09-21 23:42:10 +02:00
&&
2024-09-29 23:00:32 +02:00
TestStringWithRegex(item.OriginalTitle, OriginalTitle)
2024-09-21 23:42:10 +02:00
&&
2024-09-29 23:00:32 +02:00
TestStringWithRegex(item.Description, Description)
2024-09-21 23:42:10 +02:00
&&
TestComparable(item.ReleaseDate, ReleaseDate, ReleaseDateFrom, ReleaseDateTo)
&&
TestComparable(item.Length, Length, LengthFrom, LengthTo)
&&
2024-09-29 23:00:32 +02:00
Test(item.HasEnded, HasEnded)
&&
TestComparable(item.Rating.Average, RatingAverage, RatingAverageFrom, RatingAverageTo)
&&
TestComparable(item.Rating.Count, RatingCount, RatingCountFrom, RatingCountTo)
2024-09-21 23:42:10 +02:00
);
#endregion
}