Files
WatchIt/WatchIt.Common/WatchIt.Common.Model/Photos/PhotoQueryParameters.cs

49 lines
1.3 KiB
C#
Raw Normal View History

2024-09-29 23:00:32 +02:00
using System.Text.Json.Serialization;
2024-07-03 22:18:32 +02:00
using Microsoft.AspNetCore.Mvc;
2024-09-25 22:11:28 +02:00
using WatchIt.Common.Model.Media;
2024-09-29 23:00:32 +02:00
using WatchIt.Common.Model.Series;
2024-07-03 22:18:32 +02:00
using WatchIt.Common.Query;
2024-09-25 22:11:28 +02:00
namespace WatchIt.Common.Model.Photos;
2024-07-03 22:18:32 +02:00
2024-09-25 22:11:28 +02:00
public class PhotoQueryParameters : QueryParameters<PhotoResponse>
2024-07-03 22:18:32 +02:00
{
#region PROPERTIES
[FromQuery(Name = "mime_type")]
public string? MimeType { get; set; }
[FromQuery(Name = "is_background")]
public bool? IsBackground { get; set; }
[FromQuery(Name = "is_universal_background")]
public bool? IsUniversalBackground { get; set; }
2024-09-25 22:11:28 +02:00
[FromQuery(Name = "upload_date")]
public DateOnly? UploadDate { get; set; }
[FromQuery(Name = "upload_date_from")]
public DateOnly? UploadDateFrom { get; set; }
[FromQuery(Name = "upload_date_to")]
public DateOnly? UploadDateTo { get; set; }
2024-07-03 22:18:32 +02:00
#endregion
2024-10-02 16:09:11 +02:00
#region PRIVATE METHODS
2024-07-03 22:18:32 +02:00
2024-10-02 16:09:11 +02:00
protected override bool IsMeetingConditions(PhotoResponse item) =>
2024-07-03 22:18:32 +02:00
(
2024-09-29 23:00:32 +02:00
TestStringWithRegex(item.MimeType, MimeType)
2024-07-03 22:18:32 +02:00
&&
2024-09-29 23:00:32 +02:00
Test(item.Background is not null, IsBackground)
2024-07-03 22:18:32 +02:00
&&
2024-09-29 23:00:32 +02:00
Test(item.Background is not null && item.Background.IsUniversalBackground, IsUniversalBackground)
2024-09-25 22:11:28 +02:00
&&
TestComparable(item.UploadDate, UploadDate, UploadDateFrom, UploadDateTo)
2024-07-03 22:18:32 +02:00
);
#endregion
}