roles controller added
This commit is contained in:
13
WatchIt.Common/WatchIt.Common.Model/Roles/Role.cs
Normal file
13
WatchIt.Common/WatchIt.Common.Model/Roles/Role.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace WatchIt.Common.Model.Roles;
|
||||
|
||||
public class Role
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
[JsonPropertyName("name")]
|
||||
public required string Name { get; set; }
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using WatchIt.Common.Query;
|
||||
|
||||
namespace WatchIt.Common.Model.Roles;
|
||||
|
||||
public class RoleQueryParameters : QueryParameters<RoleResponse>
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
[FromQuery(Name = "name")]
|
||||
public string? Name { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PRIVATE METHODS
|
||||
|
||||
protected override bool IsMeetingConditions(RoleResponse item) => TestStringWithRegex(item.Name, Name);
|
||||
|
||||
#endregion
|
||||
}
|
||||
18
WatchIt.Common/WatchIt.Common.Model/Roles/RoleRequest.cs
Normal file
18
WatchIt.Common/WatchIt.Common.Model/Roles/RoleRequest.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
namespace WatchIt.Common.Model.Roles;
|
||||
|
||||
public class RoleRequest : Role
|
||||
{
|
||||
#region PUBLIC METHODS
|
||||
|
||||
public Database.Model.Person.PersonActorRoleType CreateActorRoleType() => new Database.Model.Person.PersonActorRoleType()
|
||||
{
|
||||
Name = Name
|
||||
};
|
||||
|
||||
public Database.Model.Person.PersonCreatorRoleType CreateCreatorRoleType() => new Database.Model.Person.PersonCreatorRoleType()
|
||||
{
|
||||
Name = Name
|
||||
};
|
||||
|
||||
#endregion
|
||||
}
|
||||
45
WatchIt.Common/WatchIt.Common.Model/Roles/RoleResponse.cs
Normal file
45
WatchIt.Common/WatchIt.Common.Model/Roles/RoleResponse.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Text.Json.Serialization;
|
||||
using WatchIt.Common.Query;
|
||||
|
||||
namespace WatchIt.Common.Model.Roles;
|
||||
|
||||
public class RoleResponse : Role, IQueryOrderable<RoleResponse>
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
[JsonIgnore]
|
||||
public static IDictionary<string, Func<RoleResponse, IComparable>> OrderableProperties { get; } = new Dictionary<string, Func<RoleResponse, IComparable>>
|
||||
{
|
||||
{ "name", item => item.Name }
|
||||
};
|
||||
|
||||
|
||||
[JsonPropertyName("id")]
|
||||
public required short? Id { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region CONSTRUCTORS
|
||||
|
||||
[JsonConstructor]
|
||||
public RoleResponse() { }
|
||||
|
||||
[SetsRequiredMembers]
|
||||
public RoleResponse(Database.Model.Person.PersonCreatorRoleType creatorRoleType)
|
||||
{
|
||||
Id = creatorRoleType.Id;
|
||||
Name = creatorRoleType.Name;
|
||||
}
|
||||
|
||||
[SetsRequiredMembers]
|
||||
public RoleResponse(Database.Model.Person.PersonActorRoleType actorRoleType)
|
||||
{
|
||||
Id = actorRoleType.Id;
|
||||
Name = actorRoleType.Name;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
Reference in New Issue
Block a user