get all accounts endpoint added

This commit is contained in:
2024-11-06 16:29:24 +01:00
Unverified
parent d6fda7dbb8
commit 57fd4ba7a1
9 changed files with 113 additions and 1 deletions

View File

@@ -0,0 +1,67 @@
using Microsoft.AspNetCore.Mvc;
using WatchIt.Common.Query;
namespace WatchIt.Common.Model.Accounts;
public class AccountQueryParameters : QueryParameters<AccountResponse>
{
#region PROPERTIES
[FromQuery(Name = "username")]
public string? Username { get; set; }
[FromQuery(Name = "email")]
public string? Email { get; set; }
[FromQuery(Name = "description")]
public string? Description { get; set; }
[FromQuery(Name = "gender_id")]
public short? GenderId { get; set; }
[FromQuery(Name = "last_active")]
public DateOnly? LastActive { get; set; }
[FromQuery(Name = "last_active_from")]
public DateOnly? LastActiveFrom { get; set; }
[FromQuery(Name = "last_active_to")]
public DateOnly? LastActiveTo { get; set; }
[FromQuery(Name = "creation_date")]
public DateOnly? CreationDate { get; set; }
[FromQuery(Name = "creation_date_from")]
public DateOnly? CreationDateFrom { get; set; }
[FromQuery(Name = "creation_date_to")]
public DateOnly? CreationDateTo { get; set; }
[FromQuery(Name = "is_admin")]
public bool? IsAdmin { get; set; }
#endregion
#region PRIVATE METHODS
protected override bool IsMeetingConditions(AccountResponse item) =>
(
TestStringWithRegex(item.Username, Username)
&&
TestStringWithRegex(item.Email, Email)
&&
TestStringWithRegex(item.Description, Description)
&&
Test(item.Gender?.Id, GenderId)
&&
TestComparable(item.LastActive, LastActive, LastActiveFrom, LastActiveTo)
&&
TestComparable(item.CreationDate, CreationDate, CreationDateFrom, CreationDateTo)
&&
Test(item.IsAdmin, IsAdmin)
);
#endregion
}