-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
37407cc
commit 883ce3e
Showing
3 changed files
with
102 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using Korga.Filters.Entities; | ||
using System; | ||
|
||
namespace Korga.Models.Json; | ||
|
||
public class PersonFilterRequest | ||
{ | ||
public required string Discriminator { get; init; } | ||
public int? StatusId { get; init; } | ||
public int? GroupId { get; init; } | ||
public int? GroupTypeId { get; init; } | ||
public int? GroupRoleId { get; init; } | ||
public int? PersonId { get; init; } | ||
|
||
public PersonFilter ToEntity() | ||
{ | ||
return Discriminator switch | ||
{ | ||
nameof(StatusFilter) => new StatusFilter | ||
{ | ||
StatusId = StatusId.GetValueOrDefault() | ||
}, | ||
nameof(GroupFilter) => new GroupFilter | ||
{ | ||
GroupId = GroupId.GetValueOrDefault(), | ||
GroupRoleId = GroupRoleId | ||
}, | ||
nameof(GroupTypeFilter) => new GroupTypeFilter | ||
{ | ||
GroupTypeId = GroupTypeId.GetValueOrDefault(), | ||
GroupRoleId = GroupRoleId | ||
}, | ||
nameof(SinglePerson) => new SinglePerson | ||
{ | ||
PersonId = PersonId.GetValueOrDefault() | ||
}, | ||
_ => throw new ArgumentException($"Invalid filter type {Discriminator}") | ||
}; | ||
} | ||
} |