changes in model, actor roles adding in person edit page finished
This commit is contained in:
@@ -2,7 +2,7 @@ using System.Text.Json.Serialization;
|
|||||||
|
|
||||||
namespace WatchIt.Common.Model.Roles;
|
namespace WatchIt.Common.Model.Roles;
|
||||||
|
|
||||||
public class ActorRole
|
public abstract class ActorRole
|
||||||
{
|
{
|
||||||
#region PROPERTIES
|
#region PROPERTIES
|
||||||
|
|
||||||
@@ -12,11 +12,5 @@ public class ActorRole
|
|||||||
[JsonPropertyName("name")]
|
[JsonPropertyName("name")]
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
|
|
||||||
[JsonPropertyName("media_id")]
|
|
||||||
public long MediaId { get; set; }
|
|
||||||
|
|
||||||
[JsonPropertyName("person_id")]
|
|
||||||
public long PersonId { get; set; }
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
using System.Text.Json.Serialization;
|
||||||
|
using WatchIt.Database.Model.Person;
|
||||||
|
|
||||||
|
namespace WatchIt.Common.Model.Roles;
|
||||||
|
|
||||||
|
public class ActorRoleMediaRequest : ActorRoleRequest, IActorRoleMediaRequest
|
||||||
|
{
|
||||||
|
#region PROPERTIES
|
||||||
|
|
||||||
|
[JsonPropertyName("person_id")]
|
||||||
|
public long PersonId { get; set; }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#region PUBLIC METHODS
|
||||||
|
|
||||||
|
public PersonActorRole CreateActorRole(long mediaId) => base.CreateActorRole(mediaId, PersonId);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
using System.Text.Json.Serialization;
|
||||||
|
using WatchIt.Database.Model.Person;
|
||||||
|
|
||||||
|
namespace WatchIt.Common.Model.Roles;
|
||||||
|
|
||||||
|
public class ActorRolePersonRequest : ActorRoleRequest, IActorRolePersonRequest
|
||||||
|
{
|
||||||
|
#region PROPERTIES
|
||||||
|
|
||||||
|
[JsonPropertyName("media_id")]
|
||||||
|
public long MediaId { get; set; }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#region PUBLIC METHODS
|
||||||
|
|
||||||
|
public PersonActorRole CreateActorRole(long personId) => base.CreateActorRole(MediaId, personId);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
@@ -3,51 +3,22 @@ using WatchIt.Database.Model.Person;
|
|||||||
|
|
||||||
namespace WatchIt.Common.Model.Roles;
|
namespace WatchIt.Common.Model.Roles;
|
||||||
|
|
||||||
public class ActorRoleRequest : ActorRole, IActorRoleMediaRequest, IActorRolePersonRequest
|
public abstract class ActorRoleRequest : ActorRole
|
||||||
{
|
{
|
||||||
#region CONSTRUCTORS
|
|
||||||
|
|
||||||
[SetsRequiredMembers]
|
|
||||||
public ActorRoleRequest(ActorRoleResponse data)
|
|
||||||
{
|
|
||||||
Name = data.Name;
|
|
||||||
PersonId = data.PersonId;
|
|
||||||
MediaId = data.MediaId;
|
|
||||||
TypeId = data.TypeId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ActorRoleRequest() {}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#region PUBLIC METHODS
|
#region PUBLIC METHODS
|
||||||
|
|
||||||
PersonActorRole IActorRoleMediaRequest.CreateActorRole(long mediaId)
|
|
||||||
{
|
|
||||||
MediaId = mediaId;
|
|
||||||
return CreateActorRole();
|
|
||||||
}
|
|
||||||
|
|
||||||
PersonActorRole IActorRolePersonRequest.CreateActorRole(long personId)
|
public PersonActorRole CreateActorRole(long mediaId, long personId) => new PersonActorRole
|
||||||
{
|
{
|
||||||
PersonId = personId;
|
MediaId = mediaId,
|
||||||
return CreateActorRole();
|
PersonId = personId,
|
||||||
}
|
|
||||||
|
|
||||||
public PersonActorRole CreateActorRole() => new PersonActorRole
|
|
||||||
{
|
|
||||||
MediaId = MediaId,
|
|
||||||
PersonId = PersonId,
|
|
||||||
PersonActorRoleTypeId = TypeId,
|
PersonActorRoleTypeId = TypeId,
|
||||||
RoleName = Name,
|
RoleName = Name,
|
||||||
};
|
};
|
||||||
|
|
||||||
public void UpdateActorRole(PersonActorRole item)
|
public void UpdateActorRole(PersonActorRole item, long mediaId, long personId)
|
||||||
{
|
{
|
||||||
item.MediaId = MediaId;
|
item.MediaId = mediaId;
|
||||||
item.PersonId = PersonId;
|
item.PersonId = personId;
|
||||||
item.PersonActorRoleTypeId = TypeId;
|
item.PersonActorRoleTypeId = TypeId;
|
||||||
item.RoleName = Name;
|
item.RoleName = Name;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,12 @@ public class ActorRoleResponse : ActorRole, IQueryOrderable<ActorRoleResponse>
|
|||||||
|
|
||||||
[JsonPropertyName("id")]
|
[JsonPropertyName("id")]
|
||||||
public required Guid Id { get; set; }
|
public required Guid Id { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("media_id")]
|
||||||
|
public long MediaId { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("person_id")]
|
||||||
|
public long PersonId { get; set; }
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,43 @@
|
|||||||
|
using System.Text.Json.Serialization;
|
||||||
|
using WatchIt.Database.Model.Person;
|
||||||
|
|
||||||
|
namespace WatchIt.Common.Model.Roles;
|
||||||
|
|
||||||
|
public class ActorRoleUniversalRequest : ActorRoleRequest, IActorRolePersonRequest, IActorRoleMediaRequest
|
||||||
|
{
|
||||||
|
#region PROPERTIES
|
||||||
|
|
||||||
|
[JsonPropertyName("person_id")]
|
||||||
|
public long PersonId { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("media_id")]
|
||||||
|
public long MediaId { get; set; }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#region CONSTRUCTORS
|
||||||
|
|
||||||
|
public ActorRoleUniversalRequest() { }
|
||||||
|
|
||||||
|
public ActorRoleUniversalRequest(ActorRoleResponse data)
|
||||||
|
{
|
||||||
|
MediaId = data.MediaId;
|
||||||
|
PersonId = data.PersonId;
|
||||||
|
TypeId = data.TypeId;
|
||||||
|
Name = data.Name;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#region PUBLIC METHODS
|
||||||
|
|
||||||
|
public PersonActorRole CreateActorRole() => base.CreateActorRole(MediaId, PersonId);
|
||||||
|
|
||||||
|
public void UpdateActorRole(PersonActorRole item) => base.UpdateActorRole(item, MediaId, PersonId);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
@@ -2,18 +2,12 @@ using System.Text.Json.Serialization;
|
|||||||
|
|
||||||
namespace WatchIt.Common.Model.Roles;
|
namespace WatchIt.Common.Model.Roles;
|
||||||
|
|
||||||
public class CreatorRole
|
public abstract class CreatorRole
|
||||||
{
|
{
|
||||||
#region PROPERTIES
|
#region PROPERTIES
|
||||||
|
|
||||||
[JsonPropertyName("type_id")]
|
[JsonPropertyName("type_id")]
|
||||||
public required short TypeId { get; set; }
|
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
|
#endregion
|
||||||
}
|
}
|
||||||
@@ -3,23 +3,20 @@ using WatchIt.Database.Model.Person;
|
|||||||
|
|
||||||
namespace WatchIt.Common.Model.Roles;
|
namespace WatchIt.Common.Model.Roles;
|
||||||
|
|
||||||
public interface ICreatorRoleMediaRequest
|
public class CreatorRoleMediaRequest : CreatorRoleRequest
|
||||||
{
|
{
|
||||||
#region PROPERTIES
|
#region PROPERTIES
|
||||||
|
|
||||||
[JsonPropertyName("person_id")]
|
[JsonPropertyName("person_id")]
|
||||||
long PersonId { get; set; }
|
public required long PersonId { get; set; }
|
||||||
|
|
||||||
[JsonPropertyName("type_id")]
|
|
||||||
short TypeId { get; set; }
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#region PUBLIC METHODS
|
#region PUBLIC METHODS
|
||||||
|
|
||||||
PersonCreatorRole CreateCreatorRole(long mediaId);
|
public PersonCreatorRole CreateCreatorRole(long mediaId) => base.CreateCreatorRole(mediaId, PersonId);
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
@@ -3,23 +3,20 @@ using WatchIt.Database.Model.Person;
|
|||||||
|
|
||||||
namespace WatchIt.Common.Model.Roles;
|
namespace WatchIt.Common.Model.Roles;
|
||||||
|
|
||||||
public interface ICreatorRolePersonRequest
|
public class CreatorRolePersonRequest : CreatorRoleRequest
|
||||||
{
|
{
|
||||||
#region PROPERTIES
|
#region PROPERTIES
|
||||||
|
|
||||||
[JsonPropertyName("media_id")]
|
[JsonPropertyName("media_id")]
|
||||||
long MediaId { get; set; }
|
public required long MediaId { get; set; }
|
||||||
|
|
||||||
[JsonPropertyName("type_id")]
|
|
||||||
short TypeId { get; set; }
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#region PUBLIC METHODS
|
#region PUBLIC METHODS
|
||||||
|
|
||||||
PersonCreatorRole CreateCreatorRole(long personId);
|
public PersonCreatorRole CreateCreatorRole(long personId) => base.CreateCreatorRole(MediaId, personId);
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
@@ -2,33 +2,21 @@ using WatchIt.Database.Model.Person;
|
|||||||
|
|
||||||
namespace WatchIt.Common.Model.Roles;
|
namespace WatchIt.Common.Model.Roles;
|
||||||
|
|
||||||
public class CreatorRoleRequest : CreatorRole, ICreatorRoleMediaRequest, ICreatorRolePersonRequest
|
public abstract class CreatorRoleRequest : CreatorRole
|
||||||
{
|
{
|
||||||
#region PUBLIC METHODS
|
#region PUBLIC METHODS
|
||||||
|
|
||||||
PersonCreatorRole ICreatorRoleMediaRequest.CreateCreatorRole(long mediaId)
|
|
||||||
{
|
|
||||||
MediaId = mediaId;
|
|
||||||
return CreateCreatorRole();
|
|
||||||
}
|
|
||||||
|
|
||||||
PersonCreatorRole ICreatorRolePersonRequest.CreateCreatorRole(long personId)
|
public PersonCreatorRole CreateCreatorRole(long mediaId, long personId) => new PersonCreatorRole
|
||||||
{
|
{
|
||||||
PersonId = personId;
|
MediaId = mediaId,
|
||||||
return CreateCreatorRole();
|
PersonId = personId,
|
||||||
}
|
|
||||||
|
|
||||||
public PersonCreatorRole CreateCreatorRole() => new PersonCreatorRole
|
|
||||||
{
|
|
||||||
MediaId = MediaId,
|
|
||||||
PersonId = PersonId,
|
|
||||||
PersonCreatorRoleTypeId = TypeId,
|
PersonCreatorRoleTypeId = TypeId,
|
||||||
};
|
};
|
||||||
|
|
||||||
public void UpdateCreatorRole(PersonCreatorRole item)
|
public void UpdateCreatorRole(PersonCreatorRole item, long mediaId, long personId)
|
||||||
{
|
{
|
||||||
item.MediaId = MediaId;
|
item.MediaId = mediaId;
|
||||||
item.PersonId = PersonId;
|
item.PersonId = personId;
|
||||||
item.PersonCreatorRoleTypeId = TypeId;
|
item.PersonCreatorRoleTypeId = TypeId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,12 @@ public class CreatorRoleResponse : CreatorRole, IQueryOrderable<CreatorRoleRespo
|
|||||||
|
|
||||||
[JsonPropertyName("id")]
|
[JsonPropertyName("id")]
|
||||||
public required Guid Id { get; set; }
|
public required Guid Id { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("media_id")]
|
||||||
|
public long MediaId { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("person_id")]
|
||||||
|
public long PersonId { get; set; }
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
using System.Text.Json.Serialization;
|
||||||
|
using WatchIt.Database.Model.Person;
|
||||||
|
|
||||||
|
namespace WatchIt.Common.Model.Roles;
|
||||||
|
|
||||||
|
public class CreatorRoleUniversalRequest : CreatorRoleRequest
|
||||||
|
{
|
||||||
|
#region PROPERTIES
|
||||||
|
|
||||||
|
[JsonPropertyName("person_id")]
|
||||||
|
public long PersonId { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("media_id")]
|
||||||
|
public long MediaId { get; set; }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#region PUBLIC METHODS
|
||||||
|
|
||||||
|
public PersonCreatorRole CreateCreatorRole() => base.CreateCreatorRole(MediaId, PersonId);
|
||||||
|
|
||||||
|
public void UpdateCreatorRole(PersonCreatorRole item) => base.UpdateCreatorRole(item, MediaId, PersonId);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
@@ -1,28 +1,10 @@
|
|||||||
using System.Text.Json.Serialization;
|
|
||||||
using WatchIt.Database.Model.Person;
|
|
||||||
|
|
||||||
namespace WatchIt.Common.Model.Roles;
|
namespace WatchIt.Common.Model.Roles;
|
||||||
|
|
||||||
public interface IActorRoleMediaRequest
|
public interface IActorRoleMediaRequest : IActorRoleRequest
|
||||||
{
|
{
|
||||||
#region PROPERTIES
|
#region PROPERTIES
|
||||||
|
|
||||||
[JsonPropertyName("person_id")]
|
public long PersonId { get; set; }
|
||||||
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
|
#endregion
|
||||||
}
|
}
|
||||||
@@ -1,28 +1,10 @@
|
|||||||
using System.Text.Json.Serialization;
|
|
||||||
using WatchIt.Database.Model.Person;
|
|
||||||
|
|
||||||
namespace WatchIt.Common.Model.Roles;
|
namespace WatchIt.Common.Model.Roles;
|
||||||
|
|
||||||
public interface IActorRolePersonRequest
|
public interface IActorRolePersonRequest : IActorRoleRequest
|
||||||
{
|
{
|
||||||
#region PROPERTIES
|
#region PROPERTIES
|
||||||
|
|
||||||
[JsonPropertyName("media_id")]
|
public long MediaId { get; set; }
|
||||||
long MediaId { get; set; }
|
|
||||||
|
|
||||||
[JsonPropertyName("type_id")]
|
|
||||||
short TypeId { get; set; }
|
|
||||||
|
|
||||||
[JsonPropertyName("name")]
|
|
||||||
string Name { get; set; }
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#region PUBLIC METHODS
|
|
||||||
|
|
||||||
PersonActorRole CreateActorRole(long personId);
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
namespace WatchIt.Common.Model.Roles;
|
||||||
|
|
||||||
|
public interface IActorRoleRequest
|
||||||
|
{
|
||||||
|
#region PROPERTIES
|
||||||
|
|
||||||
|
public short TypeId { get; set; }
|
||||||
|
|
||||||
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
@@ -34,5 +34,9 @@ public class PersonActorRoleConfiguration : IEntityTypeConfiguration<PersonActor
|
|||||||
.IsRequired();
|
.IsRequired();
|
||||||
builder.Property(x => x.PersonActorRoleTypeId)
|
builder.Property(x => x.PersonActorRoleTypeId)
|
||||||
.IsRequired();
|
.IsRequired();
|
||||||
|
|
||||||
|
builder.Property(x => x.RoleName)
|
||||||
|
.HasMaxLength(100)
|
||||||
|
.IsRequired();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -183,7 +183,7 @@ public class MediaController : ControllerBase
|
|||||||
[ProducesResponseType(typeof(void), StatusCodes.Status401Unauthorized)]
|
[ProducesResponseType(typeof(void), StatusCodes.Status401Unauthorized)]
|
||||||
[ProducesResponseType(typeof(void), StatusCodes.Status403Forbidden)]
|
[ProducesResponseType(typeof(void), StatusCodes.Status403Forbidden)]
|
||||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||||
public async Task<ActionResult> PostMediaActorRole([FromRoute]long id, [FromBody]IActorRoleMediaRequest body) => await _mediaControllerService.PostMediaActorRole(id, body);
|
public async Task<ActionResult> PostMediaActorRole([FromRoute]long id, [FromBody]ActorRoleMediaRequest body) => await _mediaControllerService.PostMediaActorRole(id, body);
|
||||||
|
|
||||||
[HttpGet("{id}/roles/creator")]
|
[HttpGet("{id}/roles/creator")]
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
@@ -198,7 +198,7 @@ public class MediaController : ControllerBase
|
|||||||
[ProducesResponseType(typeof(void), StatusCodes.Status401Unauthorized)]
|
[ProducesResponseType(typeof(void), StatusCodes.Status401Unauthorized)]
|
||||||
[ProducesResponseType(typeof(void), StatusCodes.Status403Forbidden)]
|
[ProducesResponseType(typeof(void), StatusCodes.Status403Forbidden)]
|
||||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||||
public async Task<ActionResult> PostMediaCreatorRole([FromRoute]long id, [FromBody]ICreatorRoleMediaRequest body) => await _mediaControllerService.PostMediaCreatorRole(id, body);
|
public async Task<ActionResult> PostMediaCreatorRole([FromRoute]long id, [FromBody]CreatorRoleMediaRequest body) => await _mediaControllerService.PostMediaCreatorRole(id, body);
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ public class PersonsController : ControllerBase
|
|||||||
[ProducesResponseType(typeof(void), StatusCodes.Status401Unauthorized)]
|
[ProducesResponseType(typeof(void), StatusCodes.Status401Unauthorized)]
|
||||||
[ProducesResponseType(typeof(void), StatusCodes.Status403Forbidden)]
|
[ProducesResponseType(typeof(void), StatusCodes.Status403Forbidden)]
|
||||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||||
public async Task<ActionResult> PostPersonActorRole([FromRoute]long id, [FromBody]IActorRolePersonRequest body) => await _personsControllerService.PostPersonActorRole(id, body);
|
public async Task<ActionResult> PostPersonActorRole([FromRoute]long id, [FromBody]ActorRolePersonRequest body) => await _personsControllerService.PostPersonActorRole(id, body);
|
||||||
|
|
||||||
[HttpGet("{id}/roles/creator")]
|
[HttpGet("{id}/roles/creator")]
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
@@ -137,7 +137,7 @@ public class PersonsController : ControllerBase
|
|||||||
[ProducesResponseType(typeof(void), StatusCodes.Status401Unauthorized)]
|
[ProducesResponseType(typeof(void), StatusCodes.Status401Unauthorized)]
|
||||||
[ProducesResponseType(typeof(void), StatusCodes.Status403Forbidden)]
|
[ProducesResponseType(typeof(void), StatusCodes.Status403Forbidden)]
|
||||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||||
public async Task<ActionResult> PostPersonCreatorRole([FromRoute]long id, [FromBody]ICreatorRolePersonRequest body) => await _personsControllerService.PostPersonCreatorRole(id, body);
|
public async Task<ActionResult> PostPersonCreatorRole([FromRoute]long id, [FromBody]CreatorRolePersonRequest body) => await _personsControllerService.PostPersonCreatorRole(id, body);
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ public class RolesController : ControllerBase
|
|||||||
[ProducesResponseType(typeof(void), StatusCodes.Status401Unauthorized)]
|
[ProducesResponseType(typeof(void), StatusCodes.Status401Unauthorized)]
|
||||||
[ProducesResponseType(typeof(void), StatusCodes.Status403Forbidden)]
|
[ProducesResponseType(typeof(void), StatusCodes.Status403Forbidden)]
|
||||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||||
public async Task<ActionResult> PutActorRole([FromRoute]Guid id, [FromBody]ActorRoleRequest body) => await _rolesControllerService.PutActorRole(id, body);
|
public async Task<ActionResult> PutActorRole([FromRoute]Guid id, [FromBody]ActorRoleUniversalRequest body) => await _rolesControllerService.PutActorRole(id, body);
|
||||||
|
|
||||||
[HttpDelete("actor/{id}")]
|
[HttpDelete("actor/{id}")]
|
||||||
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
|
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
|
||||||
@@ -98,7 +98,7 @@ public class RolesController : ControllerBase
|
|||||||
[ProducesResponseType(typeof(void), StatusCodes.Status401Unauthorized)]
|
[ProducesResponseType(typeof(void), StatusCodes.Status401Unauthorized)]
|
||||||
[ProducesResponseType(typeof(void), StatusCodes.Status403Forbidden)]
|
[ProducesResponseType(typeof(void), StatusCodes.Status403Forbidden)]
|
||||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||||
public async Task<ActionResult> PutCreatorRole([FromRoute]Guid id, [FromBody]CreatorRoleRequest body) => await _rolesControllerService.PutCreatorRole(id, body);
|
public async Task<ActionResult> PutCreatorRole([FromRoute]Guid id, [FromBody]CreatorRoleUniversalRequest body) => await _rolesControllerService.PutCreatorRole(id, body);
|
||||||
|
|
||||||
[HttpDelete("creator/{id}")]
|
[HttpDelete("creator/{id}")]
|
||||||
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
|
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ public interface IMediaControllerService
|
|||||||
Task<RequestResult> PostMediaPhoto(long mediaId, MediaPhotoRequest data);
|
Task<RequestResult> PostMediaPhoto(long mediaId, MediaPhotoRequest data);
|
||||||
|
|
||||||
Task<RequestResult> GetMediaAllActorRoles(long mediaId, ActorRoleMediaQueryParameters queryParameters);
|
Task<RequestResult> GetMediaAllActorRoles(long mediaId, ActorRoleMediaQueryParameters queryParameters);
|
||||||
Task<RequestResult> PostMediaActorRole(long mediaId, IActorRoleMediaRequest data);
|
Task<RequestResult> PostMediaActorRole(long mediaId, ActorRoleMediaRequest data);
|
||||||
Task<RequestResult> GetMediaAllCreatorRoles(long mediaId, CreatorRoleMediaQueryParameters queryParameters);
|
Task<RequestResult> GetMediaAllCreatorRoles(long mediaId, CreatorRoleMediaQueryParameters queryParameters);
|
||||||
Task<RequestResult> PostMediaCreatorRole(long mediaId, ICreatorRoleMediaRequest data);
|
Task<RequestResult> PostMediaCreatorRole(long mediaId, CreatorRoleMediaRequest data);
|
||||||
}
|
}
|
||||||
@@ -377,7 +377,7 @@ public class MediaControllerService(DatabaseContext database, IUserService userS
|
|||||||
return RequestResult.Ok(data);
|
return RequestResult.Ok(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<RequestResult> PostMediaActorRole(long mediaId, IActorRoleMediaRequest data)
|
public async Task<RequestResult> PostMediaActorRole(long mediaId, ActorRoleMediaRequest data)
|
||||||
{
|
{
|
||||||
UserValidator validator = userService.GetValidator().MustBeAdmin();
|
UserValidator validator = userService.GetValidator().MustBeAdmin();
|
||||||
if (!validator.IsValid)
|
if (!validator.IsValid)
|
||||||
@@ -412,7 +412,7 @@ public class MediaControllerService(DatabaseContext database, IUserService userS
|
|||||||
return RequestResult.Ok(data);
|
return RequestResult.Ok(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<RequestResult> PostMediaCreatorRole(long mediaId, ICreatorRoleMediaRequest data)
|
public async Task<RequestResult> PostMediaCreatorRole(long mediaId, CreatorRoleMediaRequest data)
|
||||||
{
|
{
|
||||||
UserValidator validator = userService.GetValidator().MustBeAdmin();
|
UserValidator validator = userService.GetValidator().MustBeAdmin();
|
||||||
if (!validator.IsValid)
|
if (!validator.IsValid)
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ public interface IPersonsControllerService
|
|||||||
Task<RequestResult> DeletePersonPhoto(long id);
|
Task<RequestResult> DeletePersonPhoto(long id);
|
||||||
|
|
||||||
Task<RequestResult> GetPersonAllActorRoles(long personId, ActorRolePersonQueryParameters queryParameters);
|
Task<RequestResult> GetPersonAllActorRoles(long personId, ActorRolePersonQueryParameters queryParameters);
|
||||||
Task<RequestResult> PostPersonActorRole(long personId, IActorRolePersonRequest data);
|
Task<RequestResult> PostPersonActorRole(long personId, ActorRolePersonRequest data);
|
||||||
Task<RequestResult> GetPersonAllCreatorRoles(long personId, CreatorRolePersonQueryParameters queryParameters);
|
Task<RequestResult> GetPersonAllCreatorRoles(long personId, CreatorRolePersonQueryParameters queryParameters);
|
||||||
Task<RequestResult> PostPersonCreatorRole(long personId, ICreatorRolePersonRequest data);
|
Task<RequestResult> PostPersonCreatorRole(long personId, CreatorRolePersonRequest data);
|
||||||
}
|
}
|
||||||
@@ -235,7 +235,7 @@ public class PersonsControllerService : IPersonsControllerService
|
|||||||
return RequestResult.Ok(data);
|
return RequestResult.Ok(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<RequestResult> PostPersonActorRole(long personId, IActorRolePersonRequest data)
|
public async Task<RequestResult> PostPersonActorRole(long personId, ActorRolePersonRequest data)
|
||||||
{
|
{
|
||||||
UserValidator validator = _userService.GetValidator().MustBeAdmin();
|
UserValidator validator = _userService.GetValidator().MustBeAdmin();
|
||||||
if (!validator.IsValid)
|
if (!validator.IsValid)
|
||||||
@@ -243,7 +243,7 @@ public class PersonsControllerService : IPersonsControllerService
|
|||||||
return RequestResult.Forbidden();
|
return RequestResult.Forbidden();
|
||||||
}
|
}
|
||||||
|
|
||||||
Database.Model.Person.Person? person = await _database.Persons.FirstOrDefaultAsync(x => x.Id == personId);
|
Person? person = await _database.Persons.FirstOrDefaultAsync(x => x.Id == personId);
|
||||||
if (person is null)
|
if (person is null)
|
||||||
{
|
{
|
||||||
return RequestResult.NotFound();
|
return RequestResult.NotFound();
|
||||||
@@ -258,7 +258,7 @@ public class PersonsControllerService : IPersonsControllerService
|
|||||||
|
|
||||||
public async Task<RequestResult> GetPersonAllCreatorRoles(long personId, CreatorRolePersonQueryParameters queryParameters)
|
public async Task<RequestResult> GetPersonAllCreatorRoles(long personId, CreatorRolePersonQueryParameters queryParameters)
|
||||||
{
|
{
|
||||||
Database.Model.Person.Person? media = await _database.Persons.FirstOrDefaultAsync(x => x.Id == personId);
|
Person? media = await _database.Persons.FirstOrDefaultAsync(x => x.Id == personId);
|
||||||
if (media is null)
|
if (media is null)
|
||||||
{
|
{
|
||||||
return RequestResult.NotFound();
|
return RequestResult.NotFound();
|
||||||
@@ -270,7 +270,7 @@ public class PersonsControllerService : IPersonsControllerService
|
|||||||
return RequestResult.Ok(data);
|
return RequestResult.Ok(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<RequestResult> PostPersonCreatorRole(long personId, ICreatorRolePersonRequest data)
|
public async Task<RequestResult> PostPersonCreatorRole(long personId, CreatorRolePersonRequest data)
|
||||||
{
|
{
|
||||||
UserValidator validator = _userService.GetValidator().MustBeAdmin();
|
UserValidator validator = _userService.GetValidator().MustBeAdmin();
|
||||||
if (!validator.IsValid)
|
if (!validator.IsValid)
|
||||||
@@ -278,7 +278,7 @@ public class PersonsControllerService : IPersonsControllerService
|
|||||||
return RequestResult.Forbidden();
|
return RequestResult.Forbidden();
|
||||||
}
|
}
|
||||||
|
|
||||||
Database.Model.Person.Person? media = await _database.Persons.FirstOrDefaultAsync(x => x.Id == personId);
|
Person? media = await _database.Persons.FirstOrDefaultAsync(x => x.Id == personId);
|
||||||
if (media is null)
|
if (media is null)
|
||||||
{
|
{
|
||||||
return RequestResult.NotFound();
|
return RequestResult.NotFound();
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ namespace WatchIt.WebAPI.Services.Controllers.Roles;
|
|||||||
public interface IRolesControllerService
|
public interface IRolesControllerService
|
||||||
{
|
{
|
||||||
Task<RequestResult> GetActorRole(Guid id);
|
Task<RequestResult> GetActorRole(Guid id);
|
||||||
Task<RequestResult> PutActorRole(Guid id, ActorRoleRequest data);
|
Task<RequestResult> PutActorRole(Guid id, ActorRoleUniversalRequest data);
|
||||||
Task<RequestResult> DeleteActorRole(Guid id);
|
Task<RequestResult> DeleteActorRole(Guid id);
|
||||||
Task<RequestResult> GetAllActorRoleTypes(RoleTypeQueryParameters query);
|
Task<RequestResult> GetAllActorRoleTypes(RoleTypeQueryParameters query);
|
||||||
Task<RequestResult> GetActorRoleType(short typeId);
|
Task<RequestResult> GetActorRoleType(short typeId);
|
||||||
@@ -14,7 +14,7 @@ public interface IRolesControllerService
|
|||||||
Task<RequestResult> DeleteActorRoleType(short typeId);
|
Task<RequestResult> DeleteActorRoleType(short typeId);
|
||||||
|
|
||||||
Task<RequestResult> GetCreatorRole(Guid id);
|
Task<RequestResult> GetCreatorRole(Guid id);
|
||||||
Task<RequestResult> PutCreatorRole(Guid id, CreatorRoleRequest data);
|
Task<RequestResult> PutCreatorRole(Guid id, CreatorRoleUniversalRequest data);
|
||||||
Task<RequestResult> DeleteCreatorRole(Guid id);
|
Task<RequestResult> DeleteCreatorRole(Guid id);
|
||||||
Task<RequestResult> GetAllCreatorRoleTypes(RoleTypeQueryParameters query);
|
Task<RequestResult> GetAllCreatorRoleTypes(RoleTypeQueryParameters query);
|
||||||
Task<RequestResult> GetCreatorRoleType(short typeId);
|
Task<RequestResult> GetCreatorRoleType(short typeId);
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ public class RolesControllerService : IRolesControllerService
|
|||||||
return RequestResult.Ok(data);
|
return RequestResult.Ok(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<RequestResult> PutActorRole(Guid id, ActorRoleRequest data)
|
public async Task<RequestResult> PutActorRole(Guid id, ActorRoleUniversalRequest data)
|
||||||
{
|
{
|
||||||
UserValidator validator = _userService.GetValidator().MustBeAdmin();
|
UserValidator validator = _userService.GetValidator().MustBeAdmin();
|
||||||
if (!validator.IsValid)
|
if (!validator.IsValid)
|
||||||
@@ -159,7 +159,7 @@ public class RolesControllerService : IRolesControllerService
|
|||||||
return RequestResult.Ok(data);
|
return RequestResult.Ok(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<RequestResult> PutCreatorRole(Guid id, CreatorRoleRequest data)
|
public async Task<RequestResult> PutCreatorRole(Guid id, CreatorRoleUniversalRequest data)
|
||||||
{
|
{
|
||||||
UserValidator validator = _userService.GetValidator().MustBeAdmin();
|
UserValidator validator = _userService.GetValidator().MustBeAdmin();
|
||||||
if (!validator.IsValid)
|
if (!validator.IsValid)
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
using FluentValidation;
|
||||||
|
using WatchIt.Common.Model.Roles;
|
||||||
|
using WatchIt.Database;
|
||||||
|
|
||||||
|
namespace WatchIt.WebAPI.Validators.Roles;
|
||||||
|
|
||||||
|
public class ActorRoleMediaRequestValidator : AbstractValidator<ActorRoleMediaRequest>
|
||||||
|
{
|
||||||
|
public ActorRoleMediaRequestValidator(DatabaseContext database)
|
||||||
|
{
|
||||||
|
Include(new BaseActorRoleRequestValidator(database));
|
||||||
|
RuleFor(x => x.PersonId).NotEmpty()
|
||||||
|
.NotNull()
|
||||||
|
.MustBeIn(database.Persons.Select(x => x.Id).ToList());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
using FluentValidation;
|
||||||
|
using WatchIt.Common.Model.Roles;
|
||||||
|
using WatchIt.Database;
|
||||||
|
|
||||||
|
namespace WatchIt.WebAPI.Validators.Roles;
|
||||||
|
|
||||||
|
public class ActorRolePersonRequestValidator : AbstractValidator<ActorRolePersonRequest>
|
||||||
|
{
|
||||||
|
public ActorRolePersonRequestValidator(DatabaseContext database)
|
||||||
|
{
|
||||||
|
Include(new BaseActorRoleRequestValidator(database));
|
||||||
|
RuleFor(x => x.MediaId).NotEmpty()
|
||||||
|
.NotNull()
|
||||||
|
.MustBeIn(database.Media.Select(x => x.Id).ToList());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
using FluentValidation;
|
||||||
|
using WatchIt.Common.Model.Roles;
|
||||||
|
using WatchIt.Database;
|
||||||
|
|
||||||
|
namespace WatchIt.WebAPI.Validators.Roles;
|
||||||
|
|
||||||
|
public class ActorRoleUniversalRequestValidator : AbstractValidator<ActorRoleUniversalRequest>
|
||||||
|
{
|
||||||
|
public ActorRoleUniversalRequestValidator(DatabaseContext database)
|
||||||
|
{
|
||||||
|
Include(new BaseActorRoleRequestValidator(database));
|
||||||
|
RuleFor(x => x.PersonId).NotEmpty()
|
||||||
|
.NotNull()
|
||||||
|
.MustBeIn(database.Persons.Select(x => x.Id).ToList());
|
||||||
|
RuleFor(x => x.MediaId).NotEmpty()
|
||||||
|
.NotNull()
|
||||||
|
.MustBeIn(database.Media.Select(x => x.Id).ToList());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
using FluentValidation;
|
||||||
|
using WatchIt.Common.Model.Roles;
|
||||||
|
using WatchIt.Database;
|
||||||
|
|
||||||
|
namespace WatchIt.WebAPI.Validators.Roles;
|
||||||
|
|
||||||
|
public class BaseActorRoleRequestValidator : AbstractValidator<ActorRoleRequest>
|
||||||
|
{
|
||||||
|
public BaseActorRoleRequestValidator(DatabaseContext database)
|
||||||
|
{
|
||||||
|
RuleFor(x => x.Name).NotEmpty()
|
||||||
|
.MaximumLength(100);
|
||||||
|
RuleFor(x => x.TypeId).NotEmpty()
|
||||||
|
.NotNull()
|
||||||
|
.MustBeIn(database.PersonActorRoleTypes.Select(x => x.Id).ToList());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -31,7 +31,7 @@ public interface IMediaWebAPIService
|
|||||||
Task PostMediaPhoto(long mediaId, MediaPhotoRequest data, Action? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null, Action? notFoundAction = null);
|
Task PostMediaPhoto(long mediaId, MediaPhotoRequest data, Action? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null, Action? notFoundAction = null);
|
||||||
|
|
||||||
Task GetMediaAllActorRoles(long id, ActorRoleMediaQueryParameters? query = null, Action<IEnumerable<ActorRoleResponse>>? successAction = null);
|
Task GetMediaAllActorRoles(long id, ActorRoleMediaQueryParameters? query = null, Action<IEnumerable<ActorRoleResponse>>? successAction = null);
|
||||||
Task PostMediaActorRole(long id, IActorRoleMediaRequest data, Action<ActorRoleResponse>? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null);
|
Task PostMediaActorRole(long id, ActorRoleMediaRequest data, Action<ActorRoleResponse>? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null);
|
||||||
Task GetMediaAllCreatorRoles(long id, CreatorRoleMediaQueryParameters? query = null, Action<IEnumerable<CreatorRoleResponse>>? successAction = null);
|
Task GetMediaAllCreatorRoles(long id, CreatorRoleMediaQueryParameters? query = null, Action<IEnumerable<CreatorRoleResponse>>? successAction = null);
|
||||||
Task PostMediaCreatorRole(long id, ICreatorRoleMediaRequest data, Action<CreatorRoleResponse>? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null);
|
Task PostMediaCreatorRole(long id, CreatorRoleMediaRequest data, Action<CreatorRoleResponse>? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null);
|
||||||
}
|
}
|
||||||
@@ -285,7 +285,7 @@ public class MediaWebAPIService : BaseWebAPIService, IMediaWebAPIService
|
|||||||
.ExecuteAction();
|
.ExecuteAction();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task PostMediaActorRole(long id, IActorRoleMediaRequest data, Action<ActorRoleResponse>? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null)
|
public async Task PostMediaActorRole(long id, ActorRoleMediaRequest data, Action<ActorRoleResponse>? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null)
|
||||||
{
|
{
|
||||||
string url = GetUrl(EndpointsConfiguration.Media.PostMediaActorRole, id);
|
string url = GetUrl(EndpointsConfiguration.Media.PostMediaActorRole, id);
|
||||||
|
|
||||||
@@ -312,7 +312,7 @@ public class MediaWebAPIService : BaseWebAPIService, IMediaWebAPIService
|
|||||||
.ExecuteAction();
|
.ExecuteAction();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task PostMediaCreatorRole(long id, ICreatorRoleMediaRequest data, Action<CreatorRoleResponse>? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null)
|
public async Task PostMediaCreatorRole(long id, CreatorRoleMediaRequest data, Action<CreatorRoleResponse>? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null)
|
||||||
{
|
{
|
||||||
string url = GetUrl(EndpointsConfiguration.Media.PostMediaCreatorRole, id);
|
string url = GetUrl(EndpointsConfiguration.Media.PostMediaCreatorRole, id);
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ public interface IPersonsWebAPIService
|
|||||||
Task DeletePersonPhoto(long id, Action? successAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null);
|
Task DeletePersonPhoto(long id, Action? successAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null);
|
||||||
|
|
||||||
Task GetPersonAllActorRoles(long id, ActorRolePersonQueryParameters? query = null, Action<IEnumerable<ActorRoleResponse>>? successAction = null);
|
Task GetPersonAllActorRoles(long id, ActorRolePersonQueryParameters? query = null, Action<IEnumerable<ActorRoleResponse>>? successAction = null);
|
||||||
Task PostPersonActorRole(long id, IActorRolePersonRequest data, Action<ActorRoleResponse>? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null);
|
Task PostPersonActorRole(long id, ActorRolePersonRequest data, Action<ActorRoleResponse>? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null);
|
||||||
Task GetPersonAllCreatorRoles(long id, CreatorRolePersonQueryParameters? query = null, Action<IEnumerable<CreatorRoleResponse>>? successAction = null);
|
Task GetPersonAllCreatorRoles(long id, CreatorRolePersonQueryParameters? query = null, Action<IEnumerable<CreatorRoleResponse>>? successAction = null);
|
||||||
Task PostPersonCreatorRole(long id, ICreatorRolePersonRequest data, Action<CreatorRoleResponse>? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null);
|
Task PostPersonCreatorRole(long id, CreatorRolePersonRequest data, Action<CreatorRoleResponse>? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null);
|
||||||
}
|
}
|
||||||
@@ -202,7 +202,7 @@ public class PersonsWebAPIService : BaseWebAPIService, IPersonsWebAPIService
|
|||||||
.ExecuteAction();
|
.ExecuteAction();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task PostPersonActorRole(long id, IActorRolePersonRequest data, Action<ActorRoleResponse>? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null)
|
public async Task PostPersonActorRole(long id, ActorRolePersonRequest data, Action<ActorRoleResponse>? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null)
|
||||||
{
|
{
|
||||||
string url = GetUrl(EndpointsConfiguration.Persons.PostPersonActorRole, id);
|
string url = GetUrl(EndpointsConfiguration.Persons.PostPersonActorRole, id);
|
||||||
|
|
||||||
@@ -229,7 +229,7 @@ public class PersonsWebAPIService : BaseWebAPIService, IPersonsWebAPIService
|
|||||||
.ExecuteAction();
|
.ExecuteAction();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task PostPersonCreatorRole(long id, ICreatorRolePersonRequest data, Action<CreatorRoleResponse>? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null)
|
public async Task PostPersonCreatorRole(long id, CreatorRolePersonRequest data, Action<CreatorRoleResponse>? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null)
|
||||||
{
|
{
|
||||||
string url = GetUrl(EndpointsConfiguration.Persons.PostPersonCreatorRole, id);
|
string url = GetUrl(EndpointsConfiguration.Persons.PostPersonCreatorRole, id);
|
||||||
|
|
||||||
|
|||||||
@@ -5,14 +5,15 @@ namespace WatchIt.Website.Services.WebAPI.Roles;
|
|||||||
public interface IRolesWebAPIService
|
public interface IRolesWebAPIService
|
||||||
{
|
{
|
||||||
Task GetActorRole(Guid id, Action<ActorRoleResponse>? successAction = null, Action? notFoundAction = null);
|
Task GetActorRole(Guid id, Action<ActorRoleResponse>? successAction = null, Action? notFoundAction = null);
|
||||||
Task PutActorRole(Guid id, ActorRoleRequest data, Action? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null, Action? notFoundAction = null);
|
Task PutActorRole(Guid id, ActorRoleUniversalRequest data, Action? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null, Action? notFoundAction = null);
|
||||||
Task DeleteActorRole(Guid id, Action? successAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null);
|
Task DeleteActorRole(Guid id, Action? successAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null);
|
||||||
Task GetAllActorRoleTypes(RoleTypeQueryParameters? query = null, Action<IEnumerable<RoleTypeResponse>>? successAction = null);
|
Task GetAllActorRoleTypes(RoleTypeQueryParameters? query = null, Action<IEnumerable<RoleTypeResponse>>? successAction = null);
|
||||||
Task GetActorRoleType(long typeId, Action<RoleTypeResponse>? successAction = null, Action? notFoundAction = null);
|
Task GetActorRoleType(long typeId, Action<RoleTypeResponse>? successAction = null, Action? notFoundAction = null);
|
||||||
Task PostActorRoleType(RoleTypeRequest data, Action<RoleTypeResponse>? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null);
|
Task PostActorRoleType(RoleTypeRequest data, Action<RoleTypeResponse>? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null);
|
||||||
Task DeleteActorRoleType(long typeId, Action? successAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null);
|
Task DeleteActorRoleType(long typeId, Action? successAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null);
|
||||||
|
|
||||||
Task GetCreatorRole(Guid id, Action<CreatorRoleResponse>? successAction = null, Action? notFoundAction = null);
|
Task GetCreatorRole(Guid id, Action<CreatorRoleResponse>? successAction = null, Action? notFoundAction = null);
|
||||||
Task PutCreatorRole(Guid id, CreatorRoleRequest data, Action? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null, Action? notFoundAction = null);
|
Task PutCreatorRole(Guid id, CreatorRoleUniversalRequest data, Action? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null, Action? notFoundAction = null);
|
||||||
Task DeleteCreatorRole(Guid id, Action? successAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null);
|
Task DeleteCreatorRole(Guid id, Action? successAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null);
|
||||||
Task GetAllCreatorRoleTypes(RoleTypeQueryParameters? query = null, Action<IEnumerable<RoleTypeResponse>>? successAction = null);
|
Task GetAllCreatorRoleTypes(RoleTypeQueryParameters? query = null, Action<IEnumerable<RoleTypeResponse>>? successAction = null);
|
||||||
Task GetCreatorRoleType(long typeId, Action<RoleTypeResponse>? successAction = null, Action? notFoundAction = null);
|
Task GetCreatorRoleType(long typeId, Action<RoleTypeResponse>? successAction = null, Action? notFoundAction = null);
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ public class RolesWebAPIService : BaseWebAPIService, IRolesWebAPIService
|
|||||||
.ExecuteAction();
|
.ExecuteAction();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task PutActorRole(Guid id, ActorRoleRequest data, Action? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null, Action? notFoundAction = null)
|
public async Task PutActorRole(Guid id, ActorRoleUniversalRequest data, Action? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null, Action? notFoundAction = null)
|
||||||
{
|
{
|
||||||
string url = GetUrl(EndpointsConfiguration.Roles.PutActorRole, id);
|
string url = GetUrl(EndpointsConfiguration.Roles.PutActorRole, id);
|
||||||
|
|
||||||
@@ -139,7 +139,7 @@ public class RolesWebAPIService : BaseWebAPIService, IRolesWebAPIService
|
|||||||
.ExecuteAction();
|
.ExecuteAction();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task PutCreatorRole(Guid id, CreatorRoleRequest data, Action? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null, Action? notFoundAction = null)
|
public async Task PutCreatorRole(Guid id, CreatorRoleUniversalRequest data, Action? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null, Action? notFoundAction = null)
|
||||||
{
|
{
|
||||||
string url = GetUrl(EndpointsConfiguration.Roles.PutCreatorRole, id);
|
string url = GetUrl(EndpointsConfiguration.Roles.PutCreatorRole, id);
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
@using Blazorise.Extensions
|
@using Blazorise.Extensions
|
||||||
@using WatchIt.Common.Model.Roles
|
@using WatchIt.Common.Model.Roles
|
||||||
|
@using Blazorise.Components
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -106,7 +107,44 @@
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
<EditForm Model="@(_editedModel)">
|
||||||
|
<AntiforgeryToken/>
|
||||||
|
<div class="container-grid">
|
||||||
|
<div class="row form-group mb-1">
|
||||||
|
<label for="actorFormMedia" class="col-1 col-form-label">Media:</label>
|
||||||
|
<div class="col">
|
||||||
|
<Autocomplete ElementId="actorFormMedia"
|
||||||
|
TItem="MediaResponse"
|
||||||
|
TValue="long"
|
||||||
|
Data="@(Media.Values)"
|
||||||
|
TextField="@(item => item.ReleaseDate.HasValue ? $"{item.Title} ({item.ReleaseDate.Value.Year})" : item.Title)"
|
||||||
|
ValueField="@(item => item.Id)"
|
||||||
|
@bind-SelectedValue="@(_editedModel.MediaId)"
|
||||||
|
Placeholder="Search..."
|
||||||
|
Filter="AutocompleteFilter.Contains">
|
||||||
|
<NotFoundContent Context="not_found_context"> Sorry... @not_found_context was not found</NotFoundContent>
|
||||||
|
</Autocomplete>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row form-group my-1">
|
||||||
|
<label for="actorFormType" class="col-1 col-form-label">Type:</label>
|
||||||
|
<div class="col">
|
||||||
|
<InputSelect id="actorFormType" class="form-control" TValue="short" @bind-Value="@(_editedModel.TypeId)">
|
||||||
|
@foreach (KeyValuePair<short, string> type in _roleTypes)
|
||||||
|
{
|
||||||
|
<option value="@(type.Key)">@(type.Value)</option>
|
||||||
|
}
|
||||||
|
</InputSelect>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row form-group my-1">
|
||||||
|
<label for="actorFormName" class="col-1 col-form-label">Name:</label>
|
||||||
|
<div class="col">
|
||||||
|
<InputText id="actorFormName" class="form-control" @bind-Value="@(_editedModel.Name)"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</EditForm>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ public partial class PersonRolesEditActorComponent : ComponentBase
|
|||||||
|
|
||||||
|
|
||||||
private Guid? _editedId;
|
private Guid? _editedId;
|
||||||
private IActorRolePersonRequest _editedModel = new ActorRoleRequest();
|
private IActorRolePersonRequest? _editedModel;
|
||||||
|
|
||||||
private bool _editingMode;
|
private bool _editingMode;
|
||||||
private bool _saving;
|
private bool _saving;
|
||||||
@@ -67,6 +67,7 @@ public partial class PersonRolesEditActorComponent : ComponentBase
|
|||||||
|
|
||||||
// END
|
// END
|
||||||
await Task.WhenAll(endTasks);
|
await Task.WhenAll(endTasks);
|
||||||
|
_roles = _roles.OrderBy(x => Media.First(y => y.Key == x.Value.Data.MediaId).Value.ReleaseDate).ToDictionary(x => x.Key, x => x.Value);
|
||||||
|
|
||||||
_loaded = true;
|
_loaded = true;
|
||||||
StateHasChanged();
|
StateHasChanged();
|
||||||
@@ -78,15 +79,49 @@ public partial class PersonRolesEditActorComponent : ComponentBase
|
|||||||
_editingMode = false;
|
_editingMode = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SaveEdit()
|
private async Task SaveEdit()
|
||||||
{
|
{
|
||||||
|
void SuccessPost(ActorRoleResponse data)
|
||||||
|
{
|
||||||
|
_roles[data.Id] = (data, false);
|
||||||
|
_roles = _roles.OrderBy(x => Media.First(y => y.Key == x.Value.Data.MediaId).Value.ReleaseDate).ToDictionary(x => x.Key, x => x.Value);
|
||||||
|
|
||||||
|
_saving = false;
|
||||||
|
_editingMode = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SuccessPut()
|
||||||
|
{
|
||||||
|
ActorRoleResponse temp = _roles[_editedId!.Value].Data;
|
||||||
|
temp.MediaId = _editedModel.MediaId;
|
||||||
|
temp.TypeId = _editedModel.TypeId;
|
||||||
|
temp.Name = _editedModel.Name;
|
||||||
|
|
||||||
|
_roles[_editedId!.Value] = (temp, false);
|
||||||
|
_roles = _roles.OrderBy(x => Media.First(y => y.Key == x.Value.Data.MediaId).Value.ReleaseDate).ToDictionary(x => x.Key, x => x.Value);
|
||||||
|
|
||||||
|
_saving = false;
|
||||||
|
_editingMode = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
_saving = true;
|
||||||
|
if (_editedId.HasValue)
|
||||||
|
{
|
||||||
|
await RolesWebAPIService.PutActorRole(_editedId.Value, _editedModel as ActorRoleUniversalRequest, SuccessPut);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
await PersonsWebAPIService.PostPersonActorRole(Id!.Value, _editedModel as ActorRolePersonRequest, SuccessPost);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ActivateEdit(Guid? id = null)
|
private void ActivateEdit(Guid? id = null)
|
||||||
{
|
{
|
||||||
_editedId = id;
|
_editedId = id;
|
||||||
_editedModel = id.HasValue ? new ActorRoleRequest(_roles[id.Value].Data) : new ActorRoleRequest();
|
_editedModel = id.HasValue ? new ActorRoleUniversalRequest(_roles[id.Value].Data) : new ActorRolePersonRequest()
|
||||||
|
{
|
||||||
|
TypeId = _roleTypes.Keys.First()
|
||||||
|
};
|
||||||
_editingMode = true;
|
_editingMode = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -51,7 +51,7 @@
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
<div class="d-flex align-items-center justify-content-center h-100 content-width">
|
<div class="d-flex align-items-center justify-content-center h-100 content-width">
|
||||||
<LoadingComponent/>
|
<LoadingComponent Color="white"/>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user