models added, roles endpoints in media controller added
This commit is contained in:
22
WatchIt.Common/WatchIt.Common.Model/Roles/ActorRole.cs
Normal file
22
WatchIt.Common/WatchIt.Common.Model/Roles/ActorRole.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace WatchIt.Common.Model.Roles;
|
||||
|
||||
public class ActorRole
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
[JsonPropertyName("type_id")]
|
||||
public required short TypeId { get; set; }
|
||||
|
||||
[JsonPropertyName("name")]
|
||||
public required string Name { get; set; }
|
||||
|
||||
[JsonPropertyName("media_id")]
|
||||
public required long MediaId { get; set; }
|
||||
|
||||
[JsonPropertyName("person_id")]
|
||||
public required long PersonId { get; set; }
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace WatchIt.Common.Model.Roles;
|
||||
|
||||
public class ActorRoleMediaQueryParameters : ActorRoleQueryParameters
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
[FromQuery(Name = "person_id")]
|
||||
public long? PersonId { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PRIVATE METHODS
|
||||
|
||||
protected override bool IsMeetingConditions(ActorRoleResponse item) =>
|
||||
(
|
||||
base.IsMeetingConditions(item)
|
||||
&&
|
||||
Test(item.PersonId, PersonId)
|
||||
);
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace WatchIt.Common.Model.Roles;
|
||||
|
||||
public class ActorRolePersonQueryParameters : ActorRoleQueryParameters
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
[FromQuery(Name = "media_id")]
|
||||
public long? MediaId { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PRIVATE METHODS
|
||||
|
||||
protected override bool IsMeetingConditions(ActorRoleResponse item) =>
|
||||
(
|
||||
base.IsMeetingConditions(item)
|
||||
&&
|
||||
Test(item.MediaId, MediaId)
|
||||
);
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using WatchIt.Common.Query;
|
||||
|
||||
namespace WatchIt.Common.Model.Roles;
|
||||
|
||||
public abstract class ActorRoleQueryParameters : QueryParameters<ActorRoleResponse>
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
[FromQuery(Name = "type_id")]
|
||||
public short? TypeId { get; set; }
|
||||
|
||||
[FromQuery(Name = "name")]
|
||||
public string? Name { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PRIVATE METHODS
|
||||
|
||||
protected override bool IsMeetingConditions(ActorRoleResponse item) =>
|
||||
(
|
||||
Test(item.TypeId, TypeId)
|
||||
&&
|
||||
TestStringWithRegex(item.Name, Name)
|
||||
);
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using WatchIt.Database.Model.Person;
|
||||
|
||||
namespace WatchIt.Common.Model.Roles;
|
||||
|
||||
public class ActorRoleRequest : ActorRole, IActorRoleMediaRequest, IActorRolePersonRequest
|
||||
{
|
||||
#region PUBLIC METHODS
|
||||
|
||||
PersonActorRole IActorRoleMediaRequest.CreateActorRole(long mediaId)
|
||||
{
|
||||
this.MediaId = mediaId;
|
||||
return CreateActorRole();
|
||||
}
|
||||
|
||||
public PersonActorRole CreateActorRole() => new PersonActorRole
|
||||
{
|
||||
MediaId = MediaId,
|
||||
PersonId = PersonId,
|
||||
PersonActorRoleTypeId = TypeId,
|
||||
RoleName = Name,
|
||||
};
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Text.Json.Serialization;
|
||||
using WatchIt.Common.Query;
|
||||
|
||||
namespace WatchIt.Common.Model.Roles;
|
||||
|
||||
public class ActorRoleResponse : ActorRole, IQueryOrderable<ActorRoleResponse>
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
[JsonIgnore]
|
||||
public static IDictionary<string, Func<ActorRoleResponse, IComparable>> OrderableProperties { get; } = new Dictionary<string, Func<ActorRoleResponse, IComparable>>
|
||||
{
|
||||
{ "name", item => item.Name },
|
||||
{ "type_id", item => item.TypeId },
|
||||
};
|
||||
|
||||
|
||||
[JsonPropertyName("id")]
|
||||
public required Guid Id { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region CONSTRUCTORS
|
||||
|
||||
[JsonConstructor]
|
||||
public ActorRoleResponse() {}
|
||||
|
||||
[SetsRequiredMembers]
|
||||
public ActorRoleResponse(Database.Model.Person.PersonActorRole data)
|
||||
{
|
||||
Id = data.Id;
|
||||
MediaId = data.MediaId;
|
||||
PersonId = data.PersonId;
|
||||
TypeId = data.PersonActorRoleTypeId;
|
||||
Name = data.RoleName;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
19
WatchIt.Common/WatchIt.Common.Model/Roles/CreatorRole.cs
Normal file
19
WatchIt.Common/WatchIt.Common.Model/Roles/CreatorRole.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace WatchIt.Common.Model.Roles;
|
||||
|
||||
public class CreatorRole
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
[JsonPropertyName("type_id")]
|
||||
public required short TypeId { get; set; }
|
||||
|
||||
[JsonPropertyName("media_id")]
|
||||
public required long MediaId { get; set; }
|
||||
|
||||
[JsonPropertyName("person_id")]
|
||||
public required long PersonId { get; set; }
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace WatchIt.Common.Model.Roles;
|
||||
|
||||
public class CreatorRoleMediaQueryParameters : CreatorRoleQueryParameters
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
[FromQuery(Name = "person_id")]
|
||||
public long? PersonId { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PRIVATE METHODS
|
||||
|
||||
protected override bool IsMeetingConditions(CreatorRoleResponse item) =>
|
||||
(
|
||||
base.IsMeetingConditions(item)
|
||||
&&
|
||||
Test(item.PersonId, PersonId)
|
||||
);
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace WatchIt.Common.Model.Roles;
|
||||
|
||||
public class CreatorRolePersonQueryParameters : CreatorRoleQueryParameters
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
[FromQuery(Name = "media_id")]
|
||||
public long? MediaId { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PRIVATE METHODS
|
||||
|
||||
protected override bool IsMeetingConditions(CreatorRoleResponse item) =>
|
||||
(
|
||||
base.IsMeetingConditions(item)
|
||||
&&
|
||||
Test(item.MediaId, MediaId)
|
||||
);
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using WatchIt.Common.Query;
|
||||
|
||||
namespace WatchIt.Common.Model.Roles;
|
||||
|
||||
public abstract class CreatorRoleQueryParameters : QueryParameters<CreatorRoleResponse>
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
[FromQuery(Name = "type_id")]
|
||||
public short? TypeId { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PRIVATE METHODS
|
||||
|
||||
protected override bool IsMeetingConditions(CreatorRoleResponse item) =>
|
||||
(
|
||||
Test(item.TypeId, TypeId)
|
||||
);
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using WatchIt.Database.Model.Person;
|
||||
|
||||
namespace WatchIt.Common.Model.Roles;
|
||||
|
||||
public class CreatorRoleRequest : CreatorRole, ICreatorRoleMediaRequest, ICreatorRolePersonRequest
|
||||
{
|
||||
#region PUBLIC METHODS
|
||||
|
||||
PersonCreatorRole ICreatorRoleMediaRequest.CreateCreatorRole(long mediaId)
|
||||
{
|
||||
this.MediaId = mediaId;
|
||||
return CreateCreatorRole();
|
||||
}
|
||||
|
||||
public PersonCreatorRole CreateCreatorRole() => new PersonCreatorRole
|
||||
{
|
||||
MediaId = MediaId,
|
||||
PersonId = PersonId,
|
||||
PersonCreatorRoleTypeId = TypeId,
|
||||
};
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Text.Json.Serialization;
|
||||
using WatchIt.Common.Query;
|
||||
|
||||
namespace WatchIt.Common.Model.Roles;
|
||||
|
||||
public class CreatorRoleResponse : CreatorRole, IQueryOrderable<CreatorRoleResponse>
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
[JsonIgnore]
|
||||
public static IDictionary<string, Func<CreatorRoleResponse, IComparable>> OrderableProperties { get; } = new Dictionary<string, Func<CreatorRoleResponse, IComparable>>
|
||||
{
|
||||
{ "type_id", item => item.TypeId },
|
||||
};
|
||||
|
||||
|
||||
[JsonPropertyName("id")]
|
||||
public required Guid Id { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region CONSTRUCTORS
|
||||
|
||||
[JsonConstructor]
|
||||
public CreatorRoleResponse() {}
|
||||
|
||||
[SetsRequiredMembers]
|
||||
public CreatorRoleResponse(Database.Model.Person.PersonCreatorRole data)
|
||||
{
|
||||
Id = data.Id;
|
||||
MediaId = data.MediaId;
|
||||
PersonId = data.PersonId;
|
||||
TypeId = data.PersonCreatorRoleTypeId;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
using System.Text.Json.Serialization;
|
||||
using WatchIt.Database.Model.Person;
|
||||
|
||||
namespace WatchIt.Common.Model.Roles;
|
||||
|
||||
public interface IActorRoleMediaRequest
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
[JsonPropertyName("person_id")]
|
||||
long PersonId { get; set; }
|
||||
|
||||
[JsonPropertyName("type_id")]
|
||||
short TypeId { get; set; }
|
||||
|
||||
[JsonPropertyName("name")]
|
||||
string Name { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PUBLIC METHODS
|
||||
|
||||
PersonActorRole CreateActorRole(long mediaId);
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace WatchIt.Common.Model.Roles;
|
||||
|
||||
public interface IActorRolePersonRequest
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
[JsonPropertyName("media_id")]
|
||||
long MediaId { get; set; }
|
||||
|
||||
[JsonPropertyName("type_id")]
|
||||
short TypeId { get; set; }
|
||||
|
||||
[JsonPropertyName("name")]
|
||||
string Name { get; set; }
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using System.Text.Json.Serialization;
|
||||
using WatchIt.Database.Model.Person;
|
||||
|
||||
namespace WatchIt.Common.Model.Roles;
|
||||
|
||||
public interface ICreatorRoleMediaRequest
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
[JsonPropertyName("person_id")]
|
||||
long PersonId { get; set; }
|
||||
|
||||
[JsonPropertyName("type_id")]
|
||||
short TypeId { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PUBLIC METHODS
|
||||
|
||||
PersonCreatorRole CreateCreatorRole(long mediaId);
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace WatchIt.Common.Model.Roles;
|
||||
|
||||
public interface ICreatorRolePersonRequest
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
[JsonPropertyName("media_id")]
|
||||
long MediaId { get; set; }
|
||||
|
||||
[JsonPropertyName("type_id")]
|
||||
short TypeId { get; set; }
|
||||
|
||||
#endregion
|
||||
}
|
||||
Reference in New Issue
Block a user