Merge pull request #104 from mateuszskoczek/features/role_adding
Features/role adding
This commit is contained in:
@@ -2,21 +2,15 @@ using System.Text.Json.Serialization;
|
||||
|
||||
namespace WatchIt.Common.Model.Roles;
|
||||
|
||||
public class ActorRole
|
||||
public abstract class ActorRole
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
[JsonPropertyName("type_id")]
|
||||
public required short TypeId { get; set; }
|
||||
public 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; }
|
||||
public string Name { get; set; }
|
||||
|
||||
#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
|
||||
}
|
||||
@@ -1,35 +1,24 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using WatchIt.Database.Model.Person;
|
||||
|
||||
namespace WatchIt.Common.Model.Roles;
|
||||
|
||||
public class ActorRoleRequest : ActorRole, IActorRoleMediaRequest, IActorRolePersonRequest
|
||||
public abstract class ActorRoleRequest : ActorRole, IActorRoleRequest
|
||||
{
|
||||
#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;
|
||||
return CreateActorRole();
|
||||
}
|
||||
|
||||
public PersonActorRole CreateActorRole() => new PersonActorRole
|
||||
{
|
||||
MediaId = MediaId,
|
||||
PersonId = PersonId,
|
||||
MediaId = mediaId,
|
||||
PersonId = personId,
|
||||
PersonActorRoleTypeId = TypeId,
|
||||
RoleName = Name,
|
||||
};
|
||||
|
||||
public void UpdateActorRole(PersonActorRole item)
|
||||
public void UpdateActorRole(PersonActorRole item, long mediaId, long personId)
|
||||
{
|
||||
item.MediaId = MediaId;
|
||||
item.PersonId = PersonId;
|
||||
item.MediaId = mediaId;
|
||||
item.PersonId = personId;
|
||||
item.PersonActorRoleTypeId = TypeId;
|
||||
item.RoleName = Name;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,12 @@ public class ActorRoleResponse : ActorRole, IQueryOrderable<ActorRoleResponse>
|
||||
|
||||
[JsonPropertyName("id")]
|
||||
public required Guid Id { get; set; }
|
||||
|
||||
[JsonPropertyName("media_id")]
|
||||
public long MediaId { get; set; }
|
||||
|
||||
[JsonPropertyName("person_id")]
|
||||
public long PersonId { get; set; }
|
||||
|
||||
#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;
|
||||
|
||||
public class CreatorRole
|
||||
public abstract 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; }
|
||||
public short TypeId { get; set; }
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using System.Text.Json.Serialization;
|
||||
using WatchIt.Database.Model.Person;
|
||||
|
||||
namespace WatchIt.Common.Model.Roles;
|
||||
|
||||
public class CreatorRoleMediaRequest : CreatorRoleRequest, ICreatorRoleMediaRequest
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
[JsonPropertyName("person_id")]
|
||||
public long PersonId { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PUBLIC METHODS
|
||||
|
||||
public PersonCreatorRole CreateCreatorRole(long mediaId) => base.CreateCreatorRole(mediaId, PersonId);
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using System.Text.Json.Serialization;
|
||||
using WatchIt.Database.Model.Person;
|
||||
|
||||
namespace WatchIt.Common.Model.Roles;
|
||||
|
||||
public class CreatorRolePersonRequest : CreatorRoleRequest, ICreatorRolePersonRequest
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
[JsonPropertyName("media_id")]
|
||||
public long MediaId { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PUBLIC METHODS
|
||||
|
||||
public PersonCreatorRole CreateCreatorRole(long personId) => base.CreateCreatorRole(MediaId, personId);
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -2,33 +2,21 @@ using WatchIt.Database.Model.Person;
|
||||
|
||||
namespace WatchIt.Common.Model.Roles;
|
||||
|
||||
public class CreatorRoleRequest : CreatorRole, ICreatorRoleMediaRequest, ICreatorRolePersonRequest
|
||||
public abstract class CreatorRoleRequest : CreatorRole, ICreatorRoleRequest
|
||||
{
|
||||
#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;
|
||||
return CreateCreatorRole();
|
||||
}
|
||||
|
||||
public PersonCreatorRole CreateCreatorRole() => new PersonCreatorRole
|
||||
{
|
||||
MediaId = MediaId,
|
||||
PersonId = PersonId,
|
||||
MediaId = mediaId,
|
||||
PersonId = personId,
|
||||
PersonCreatorRoleTypeId = TypeId,
|
||||
};
|
||||
|
||||
public void UpdateCreatorRole(PersonCreatorRole item)
|
||||
public void UpdateCreatorRole(PersonCreatorRole item, long mediaId, long personId)
|
||||
{
|
||||
item.MediaId = MediaId;
|
||||
item.PersonId = PersonId;
|
||||
item.MediaId = mediaId;
|
||||
item.PersonId = personId;
|
||||
item.PersonCreatorRoleTypeId = TypeId;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,12 @@ public class CreatorRoleResponse : CreatorRole, IQueryOrderable<CreatorRoleRespo
|
||||
|
||||
[JsonPropertyName("id")]
|
||||
public required Guid Id { get; set; }
|
||||
|
||||
[JsonPropertyName("media_id")]
|
||||
public long MediaId { get; set; }
|
||||
|
||||
[JsonPropertyName("person_id")]
|
||||
public long PersonId { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
using System.Text.Json.Serialization;
|
||||
using WatchIt.Database.Model.Person;
|
||||
|
||||
namespace WatchIt.Common.Model.Roles;
|
||||
|
||||
public class CreatorRoleUniversalRequest : CreatorRoleRequest, ICreatorRolePersonRequest, ICreatorRoleMediaRequest
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
[JsonPropertyName("person_id")]
|
||||
public long PersonId { get; set; }
|
||||
|
||||
[JsonPropertyName("media_id")]
|
||||
public long MediaId { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region CONSTRUCTORS
|
||||
|
||||
public CreatorRoleUniversalRequest() { }
|
||||
|
||||
public CreatorRoleUniversalRequest(CreatorRoleResponse data)
|
||||
{
|
||||
MediaId = data.MediaId;
|
||||
PersonId = data.PersonId;
|
||||
TypeId = data.TypeId;
|
||||
}
|
||||
|
||||
#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;
|
||||
|
||||
public interface IActorRoleMediaRequest
|
||||
public interface IActorRoleMediaRequest : IActorRoleRequest
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
[JsonPropertyName("person_id")]
|
||||
long PersonId { get; set; }
|
||||
public 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
|
||||
}
|
||||
@@ -1,28 +1,10 @@
|
||||
using System.Text.Json.Serialization;
|
||||
using WatchIt.Database.Model.Person;
|
||||
|
||||
namespace WatchIt.Common.Model.Roles;
|
||||
|
||||
public interface IActorRolePersonRequest
|
||||
public interface IActorRolePersonRequest : IActorRoleRequest
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
[JsonPropertyName("media_id")]
|
||||
long MediaId { get; set; }
|
||||
public 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
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -1,25 +1,10 @@
|
||||
using System.Text.Json.Serialization;
|
||||
using WatchIt.Database.Model.Person;
|
||||
|
||||
namespace WatchIt.Common.Model.Roles;
|
||||
|
||||
public interface ICreatorRoleMediaRequest
|
||||
public interface ICreatorRoleMediaRequest : ICreatorRoleRequest
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
[JsonPropertyName("person_id")]
|
||||
long PersonId { get; set; }
|
||||
public long PersonId { get; set; }
|
||||
|
||||
[JsonPropertyName("type_id")]
|
||||
short TypeId { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PUBLIC METHODS
|
||||
|
||||
PersonCreatorRole CreateCreatorRole(long mediaId);
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -1,25 +1,10 @@
|
||||
using System.Text.Json.Serialization;
|
||||
using WatchIt.Database.Model.Person;
|
||||
|
||||
namespace WatchIt.Common.Model.Roles;
|
||||
|
||||
public interface ICreatorRolePersonRequest
|
||||
public interface ICreatorRolePersonRequest : ICreatorRoleRequest
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
[JsonPropertyName("media_id")]
|
||||
long MediaId { get; set; }
|
||||
public long MediaId { get; set; }
|
||||
|
||||
[JsonPropertyName("type_id")]
|
||||
short TypeId { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PUBLIC METHODS
|
||||
|
||||
PersonCreatorRole CreateCreatorRole(long personId);
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace WatchIt.Common.Model.Roles;
|
||||
|
||||
public interface ICreatorRoleRequest
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
public short TypeId { get; set; }
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -16,7 +16,7 @@ public class RoleTypeResponse : RoleType, IQueryOrderable<RoleTypeResponse>
|
||||
|
||||
|
||||
[JsonPropertyName("id")]
|
||||
public required short? Id { get; set; }
|
||||
public required short Id { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -34,5 +34,9 @@ public class PersonActorRoleConfiguration : IEntityTypeConfiguration<PersonActor
|
||||
.IsRequired();
|
||||
builder.Property(x => x.PersonActorRoleTypeId)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.RoleName)
|
||||
.HasMaxLength(100)
|
||||
.IsRequired();
|
||||
}
|
||||
}
|
||||
@@ -38,6 +38,11 @@ public class MediaController : ControllerBase
|
||||
|
||||
#region Main
|
||||
|
||||
[HttpGet]
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(typeof(IEnumerable<MediaResponse>), StatusCodes.Status200OK)]
|
||||
public async Task<ActionResult> GetAllMedia(MediaQueryParameters query) => await _mediaControllerService.GetAllMedia(query);
|
||||
|
||||
[HttpGet("{id}")]
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(typeof(MediaResponse), StatusCodes.Status200OK)]
|
||||
@@ -178,7 +183,7 @@ public class MediaController : ControllerBase
|
||||
[ProducesResponseType(typeof(void), StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(typeof(void), StatusCodes.Status403Forbidden)]
|
||||
[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")]
|
||||
[AllowAnonymous]
|
||||
@@ -193,7 +198,7 @@ public class MediaController : ControllerBase
|
||||
[ProducesResponseType(typeof(void), StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(typeof(void), StatusCodes.Status403Forbidden)]
|
||||
[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
|
||||
|
||||
|
||||
@@ -122,7 +122,7 @@ public class PersonsController : ControllerBase
|
||||
[ProducesResponseType(typeof(void), StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(typeof(void), StatusCodes.Status403Forbidden)]
|
||||
[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")]
|
||||
[AllowAnonymous]
|
||||
@@ -137,7 +137,7 @@ public class PersonsController : ControllerBase
|
||||
[ProducesResponseType(typeof(void), StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(typeof(void), StatusCodes.Status403Forbidden)]
|
||||
[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
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ public class RolesController : ControllerBase
|
||||
[ProducesResponseType(typeof(void), StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(typeof(void), StatusCodes.Status403Forbidden)]
|
||||
[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}")]
|
||||
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
|
||||
@@ -98,7 +98,7 @@ public class RolesController : ControllerBase
|
||||
[ProducesResponseType(typeof(void), StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(typeof(void), StatusCodes.Status403Forbidden)]
|
||||
[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}")]
|
||||
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
|
||||
|
||||
@@ -8,6 +8,7 @@ namespace WatchIt.WebAPI.Services.Controllers.Media;
|
||||
|
||||
public interface IMediaControllerService
|
||||
{
|
||||
Task<RequestResult> GetAllMedia(MediaQueryParameters query);
|
||||
Task<RequestResult> GetMedia(long mediaId);
|
||||
|
||||
Task<RequestResult> GetMediaGenres(long mediaId);
|
||||
@@ -30,7 +31,7 @@ public interface IMediaControllerService
|
||||
Task<RequestResult> PostMediaPhoto(long mediaId, MediaPhotoRequest data);
|
||||
|
||||
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> PostMediaCreatorRole(long mediaId, ICreatorRoleMediaRequest data);
|
||||
Task<RequestResult> PostMediaCreatorRole(long mediaId, CreatorRoleMediaRequest data);
|
||||
}
|
||||
@@ -21,6 +21,14 @@ public class MediaControllerService(DatabaseContext database, IUserService userS
|
||||
|
||||
#region Main
|
||||
|
||||
public async Task<RequestResult> GetAllMedia(MediaQueryParameters query)
|
||||
{
|
||||
IEnumerable<Database.Model.Media.Media> rawData = await database.Media.ToListAsync();
|
||||
IEnumerable<MediaResponse> data = rawData.Select(x => new MediaResponse(x, database.MediaMovies.Any(y => y.Id == x.Id) ? MediaType.Movie : MediaType.Series));
|
||||
data = query.PrepareData(data);
|
||||
return RequestResult.Ok(data);
|
||||
}
|
||||
|
||||
public async Task<RequestResult> GetMedia(long mediaId)
|
||||
{
|
||||
Database.Model.Media.Media? item = await database.Media.FirstOrDefaultAsync(x => x.Id == mediaId);
|
||||
@@ -369,7 +377,7 @@ public class MediaControllerService(DatabaseContext database, IUserService userS
|
||||
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();
|
||||
if (!validator.IsValid)
|
||||
@@ -404,7 +412,7 @@ public class MediaControllerService(DatabaseContext database, IUserService userS
|
||||
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();
|
||||
if (!validator.IsValid)
|
||||
|
||||
@@ -19,7 +19,7 @@ public interface IPersonsControllerService
|
||||
Task<RequestResult> DeletePersonPhoto(long id);
|
||||
|
||||
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> PostPersonCreatorRole(long personId, ICreatorRolePersonRequest data);
|
||||
Task<RequestResult> PostPersonCreatorRole(long personId, CreatorRolePersonRequest data);
|
||||
}
|
||||
@@ -235,7 +235,7 @@ public class PersonsControllerService : IPersonsControllerService
|
||||
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();
|
||||
if (!validator.IsValid)
|
||||
@@ -243,7 +243,7 @@ public class PersonsControllerService : IPersonsControllerService
|
||||
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)
|
||||
{
|
||||
return RequestResult.NotFound();
|
||||
@@ -258,7 +258,7 @@ public class PersonsControllerService : IPersonsControllerService
|
||||
|
||||
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)
|
||||
{
|
||||
return RequestResult.NotFound();
|
||||
@@ -270,7 +270,7 @@ public class PersonsControllerService : IPersonsControllerService
|
||||
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();
|
||||
if (!validator.IsValid)
|
||||
@@ -278,7 +278,7 @@ public class PersonsControllerService : IPersonsControllerService
|
||||
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)
|
||||
{
|
||||
return RequestResult.NotFound();
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace WatchIt.WebAPI.Services.Controllers.Roles;
|
||||
public interface IRolesControllerService
|
||||
{
|
||||
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> GetAllActorRoleTypes(RoleTypeQueryParameters query);
|
||||
Task<RequestResult> GetActorRoleType(short typeId);
|
||||
@@ -14,7 +14,7 @@ public interface IRolesControllerService
|
||||
Task<RequestResult> DeleteActorRoleType(short typeId);
|
||||
|
||||
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> GetAllCreatorRoleTypes(RoleTypeQueryParameters query);
|
||||
Task<RequestResult> GetCreatorRoleType(short typeId);
|
||||
|
||||
@@ -46,7 +46,7 @@ public class RolesControllerService : IRolesControllerService
|
||||
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();
|
||||
if (!validator.IsValid)
|
||||
@@ -159,7 +159,7 @@ public class RolesControllerService : IRolesControllerService
|
||||
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();
|
||||
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());
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
public class Media
|
||||
{
|
||||
public string Base { get; set; }
|
||||
public string GetAllMedia { get; set; }
|
||||
public string GetMedia { get; set; }
|
||||
public string GetMediaGenres { get; set; }
|
||||
public string PostMediaGenre { get; set; }
|
||||
|
||||
@@ -8,6 +8,7 @@ namespace WatchIt.Website.Services.WebAPI.Media;
|
||||
|
||||
public interface IMediaWebAPIService
|
||||
{
|
||||
Task GetAllMedia(MediaQueryParameters? query = null, Action<IEnumerable<MediaResponse>>? successAction = null);
|
||||
Task GetMedia(long mediaId, Action<MediaResponse>? successAction = null, Action? notFoundAction = null);
|
||||
|
||||
Task GetMediaGenres(long mediaId, Action<IEnumerable<GenreResponse>>? successAction = null, Action? notFoundAction = null);
|
||||
@@ -30,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 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 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);
|
||||
}
|
||||
@@ -35,6 +35,18 @@ public class MediaWebAPIService : BaseWebAPIService, IMediaWebAPIService
|
||||
|
||||
#region Main
|
||||
|
||||
public async Task GetAllMedia(MediaQueryParameters? query = null, Action<IEnumerable<MediaResponse>>? successAction = null)
|
||||
{
|
||||
string url = GetUrl(EndpointsConfiguration.Media.GetAllMedia);
|
||||
|
||||
HttpRequest request = new HttpRequest(HttpMethodType.Get, url);
|
||||
request.Query = query;
|
||||
|
||||
HttpResponse response = await _httpClientService.SendRequestAsync(request);
|
||||
response.RegisterActionFor2XXSuccess(successAction)
|
||||
.ExecuteAction();
|
||||
}
|
||||
|
||||
public async Task GetMedia(long mediaId, Action<MediaResponse>? successAction = null, Action? notFoundAction = null)
|
||||
{
|
||||
string url = GetUrl(EndpointsConfiguration.Media.GetMedia, mediaId);
|
||||
@@ -273,7 +285,7 @@ public class MediaWebAPIService : BaseWebAPIService, IMediaWebAPIService
|
||||
.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);
|
||||
|
||||
@@ -300,7 +312,7 @@ public class MediaWebAPIService : BaseWebAPIService, IMediaWebAPIService
|
||||
.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);
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ public interface IPersonsWebAPIService
|
||||
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 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 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();
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
@@ -229,7 +229,7 @@ public class PersonsWebAPIService : BaseWebAPIService, IPersonsWebAPIService
|
||||
.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);
|
||||
|
||||
|
||||
@@ -5,14 +5,15 @@ namespace WatchIt.Website.Services.WebAPI.Roles;
|
||||
public interface IRolesWebAPIService
|
||||
{
|
||||
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 GetAllActorRoleTypes(RoleTypeQueryParameters? query = null, Action<IEnumerable<RoleTypeResponse>>? successAction = 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 DeleteActorRoleType(long typeId, Action? successAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = 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 GetAllCreatorRoleTypes(RoleTypeQueryParameters? query = null, Action<IEnumerable<RoleTypeResponse>>? successAction = null);
|
||||
Task GetCreatorRoleType(long typeId, Action<RoleTypeResponse>? successAction = null, Action? notFoundAction = null);
|
||||
|
||||
@@ -42,7 +42,7 @@ public class RolesWebAPIService : BaseWebAPIService, IRolesWebAPIService
|
||||
.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);
|
||||
|
||||
@@ -139,7 +139,7 @@ public class RolesWebAPIService : BaseWebAPIService, IRolesWebAPIService
|
||||
.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);
|
||||
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
<link rel="icon" type="image/png" href="favicon.png"/>
|
||||
|
||||
<!-- CSS -->
|
||||
<link rel="stylesheet" href="css/general.css?version=0.2.0.3"/>
|
||||
<link rel="stylesheet" href="css/main_button.css?version=0.2.0.0"/>
|
||||
<link rel="stylesheet" href="css/general.css?version=0.3.0.1"/>
|
||||
<link rel="stylesheet" href="css/main_button.css?version=0.3.0.0"/>
|
||||
<link rel="stylesheet" href="WatchIt.Website.styles.css?version=0.2.0.12"/>
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
|
||||
|
||||
|
||||
@@ -0,0 +1,156 @@
|
||||
@using Blazorise.Extensions
|
||||
@using WatchIt.Common.Model.Roles
|
||||
@using Blazorise.Components
|
||||
@using WatchIt.Common.Model.Persons
|
||||
|
||||
|
||||
|
||||
<div class="rounded-3 panel panel-regular p-3 @(Class)">
|
||||
@if (_loaded)
|
||||
{
|
||||
<div class="vstack gap-3">
|
||||
<div class="container-grid">
|
||||
<div class="row gx-2">
|
||||
<div class="col align-self-center">
|
||||
<h4 class="m-0"><strong>Actor roles</strong></h4>
|
||||
</div>
|
||||
@if (!_editingMode)
|
||||
{
|
||||
<div class="col-auto">
|
||||
<button type="button" class="btn btn-secondary" disabled="@(!Id.HasValue)" @onclick="@(() => ActivateEdit())">Add</button>
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(_error))
|
||||
{
|
||||
<div class="col-auto align-self-center">
|
||||
<span class="text-danger">@(_error)</span>
|
||||
</div>
|
||||
}
|
||||
<div class="col-auto">
|
||||
<button type="button" class="btn btn-secondary" @onclick="@(CancelEdit)">Cancel</button>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<button type="submit" class="btn btn-secondary" disabled="@(_saving)" @onclick="@(SaveEdit)">
|
||||
@if (!_saving)
|
||||
{
|
||||
<span>Save</span>
|
||||
}
|
||||
else
|
||||
{
|
||||
<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
|
||||
<span>Saving...</span>
|
||||
}
|
||||
</button>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
@if (!_editingMode)
|
||||
{
|
||||
if (_roles.IsNullOrEmpty())
|
||||
{
|
||||
<span class="text-center">No items</span>
|
||||
}
|
||||
else
|
||||
{
|
||||
<table class="table table-sm table-transparent">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">
|
||||
Person
|
||||
</th>
|
||||
<th scope="col">
|
||||
Role type
|
||||
</th>
|
||||
<th scope="col">
|
||||
Role name
|
||||
</th>
|
||||
<th class="table-cell-fit" scope="col">
|
||||
Actions
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="table-group-divider">
|
||||
@foreach (Guid roleId in _roles.Keys)
|
||||
{
|
||||
<tr>
|
||||
<td class="align-middle">
|
||||
@(Persons[_roles[roleId].Data.PersonId].Name)
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
@(_roleTypes[_roles[roleId].Data.TypeId])
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
@(_roles[roleId].Data.Name)
|
||||
</td>
|
||||
<td class="align-middle table-cell-fit">
|
||||
<div class="hstack gap-1">
|
||||
<button class="btn btn-outline-secondary btn-sm" type="button" disabled="@(!Id.HasValue || _roles[roleId].Deleting)" @onclick="@(() => ActivateEdit(roleId))"><i class="fas fa-edit"></i></button>
|
||||
<button class="btn btn-outline-danger btn-sm" type="button" disabled="@(!Id.HasValue || _roles[roleId].Deleting)" @onclick="@(() => Delete(roleId))">
|
||||
@if (_roles[roleId].Deleting)
|
||||
{
|
||||
<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
|
||||
}
|
||||
else
|
||||
{
|
||||
<i class="fa-solid fa-trash"></i>
|
||||
}
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
<EditForm Model="@(_editedModel)">
|
||||
<AntiforgeryToken/>
|
||||
<div class="container-grid">
|
||||
<div class="row form-group mb-1">
|
||||
<label for="actorFormPerson" class="col-1 col-form-label">Person:</label>
|
||||
<div class="col">
|
||||
<Autocomplete ElementId="actorFormPerson"
|
||||
TItem="PersonResponse"
|
||||
TValue="long"
|
||||
Data="@(Persons.Values)"
|
||||
TextField="@(item => item.Name)"
|
||||
ValueField="@(item => item.Id)"
|
||||
@bind-SelectedValue="@(_editedModel.PersonId)"
|
||||
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>
|
||||
}
|
||||
else
|
||||
{
|
||||
<LoadingComponent Color="white"/>
|
||||
}
|
||||
</div>
|
||||
@@ -0,0 +1,148 @@
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using WatchIt.Common.Model.Media;
|
||||
using WatchIt.Common.Model.Persons;
|
||||
using WatchIt.Common.Model.Roles;
|
||||
using WatchIt.Website.Services.WebAPI.Media;
|
||||
using WatchIt.Website.Services.WebAPI.Persons;
|
||||
using WatchIt.Website.Services.WebAPI.Roles;
|
||||
|
||||
namespace WatchIt.Website.Components.MediaEditPage;
|
||||
|
||||
public partial class MediaRolesEditActorComponent : ComponentBase
|
||||
{
|
||||
#region SERVICES
|
||||
|
||||
[Inject] private IPersonsWebAPIService PersonsWebAPIService { get; set; } = default!;
|
||||
[Inject] private IMediaWebAPIService MediaWebAPIService { get; set; } = default!;
|
||||
[Inject] private IRolesWebAPIService RolesWebAPIService { get; set; } = default!;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PARAMETERS
|
||||
|
||||
[Parameter] public required long? Id { get; set; }
|
||||
[Parameter] public required Dictionary<long, PersonResponse> Persons { get; set; }
|
||||
[Parameter] public string Class { get; set; } = string.Empty;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region FIELDS
|
||||
|
||||
private bool _loaded;
|
||||
private string? _error;
|
||||
|
||||
private Dictionary<Guid, (ActorRoleResponse Data, bool Deleting)> _roles = [];
|
||||
private Dictionary<short, string> _roleTypes = [];
|
||||
|
||||
|
||||
private Guid? _editedId;
|
||||
private IActorRoleMediaRequest? _editedModel;
|
||||
|
||||
private bool _editingMode;
|
||||
private bool _saving;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PUBLIC METHODS
|
||||
|
||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||
{
|
||||
if (firstRender)
|
||||
{
|
||||
List<Task> endTasks = new List<Task>();
|
||||
|
||||
// STEP 0
|
||||
if (Id.HasValue)
|
||||
{
|
||||
endTasks.AddRange(
|
||||
[
|
||||
MediaWebAPIService.GetMediaAllActorRoles(Id.Value, successAction: data => _roles = data.ToDictionary(x => x.Id, x => (x, false))),
|
||||
RolesWebAPIService.GetAllActorRoleTypes(successAction: data => _roleTypes = data.ToDictionary(x => x.Id, x => x.Name)),
|
||||
]);
|
||||
}
|
||||
|
||||
// END
|
||||
await Task.WhenAll(endTasks);
|
||||
|
||||
_loaded = true;
|
||||
StateHasChanged();
|
||||
}
|
||||
}
|
||||
|
||||
private void CancelEdit()
|
||||
{
|
||||
_error = null;
|
||||
_editingMode = false;
|
||||
}
|
||||
|
||||
private async Task SaveEdit()
|
||||
{
|
||||
void SuccessPost(ActorRoleResponse data)
|
||||
{
|
||||
_roles[data.Id] = (data, false);
|
||||
|
||||
_saving = false;
|
||||
_editingMode = false;
|
||||
}
|
||||
|
||||
void SuccessPut()
|
||||
{
|
||||
ActorRoleResponse temp = _roles[_editedId!.Value].Data;
|
||||
temp.PersonId = _editedModel.PersonId;
|
||||
temp.TypeId = _editedModel.TypeId;
|
||||
temp.Name = _editedModel.Name;
|
||||
|
||||
_roles[_editedId!.Value] = (temp, false);
|
||||
|
||||
_saving = false;
|
||||
_editingMode = false;
|
||||
}
|
||||
|
||||
void BadRequest(IDictionary<string, string[]> errors)
|
||||
{
|
||||
_error = errors.SelectMany(x => x.Value).FirstOrDefault() ?? "Unknown error";
|
||||
_saving = false;
|
||||
}
|
||||
|
||||
void Unauthorized()
|
||||
{
|
||||
_error = "You do not have permission to do this";
|
||||
_saving = false;
|
||||
}
|
||||
|
||||
_error = null;
|
||||
_saving = true;
|
||||
if (_editedId.HasValue)
|
||||
{
|
||||
await RolesWebAPIService.PutActorRole(_editedId.Value, _editedModel as ActorRoleUniversalRequest, SuccessPut, BadRequest, Unauthorized);
|
||||
}
|
||||
else
|
||||
{
|
||||
await MediaWebAPIService.PostMediaActorRole(Id!.Value, _editedModel as ActorRoleMediaRequest, SuccessPost, BadRequest, Unauthorized);
|
||||
}
|
||||
}
|
||||
|
||||
private void ActivateEdit(Guid? id = null)
|
||||
{
|
||||
_editedId = id;
|
||||
_editedModel = id.HasValue ? new ActorRoleUniversalRequest(_roles[id.Value].Data) : new ActorRoleMediaRequest()
|
||||
{
|
||||
TypeId = _roleTypes.Keys.First()
|
||||
};
|
||||
_editingMode = true;
|
||||
}
|
||||
|
||||
private async Task Delete(Guid id)
|
||||
{
|
||||
_roles[id] = (_roles[id].Data, true);
|
||||
await RolesWebAPIService.DeleteActorRole(id, () => _roles.Remove(id));
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,142 @@
|
||||
@using Blazorise.Extensions
|
||||
@using Blazorise.Components
|
||||
@using WatchIt.Common.Model.Persons
|
||||
|
||||
|
||||
<div class="rounded-3 panel panel-regular p-3 @(Class)">
|
||||
@if (_loaded)
|
||||
{
|
||||
<div class="vstack gap-3">
|
||||
<div class="container-grid">
|
||||
<div class="row gx-2">
|
||||
<div class="col align-self-center">
|
||||
<h4 class="m-0"><strong>Creator roles</strong></h4>
|
||||
</div>
|
||||
@if (!_editingMode)
|
||||
{
|
||||
<div class="col-auto">
|
||||
<button type="button" class="btn btn-secondary" disabled="@(!Id.HasValue)" @onclick="@(() => ActivateEdit())">Add</button>
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(_error))
|
||||
{
|
||||
<div class="col-auto align-self-center">
|
||||
<span class="text-danger">@(_error)</span>
|
||||
</div>
|
||||
}
|
||||
<div class="col-auto">
|
||||
<button type="button" class="btn btn-secondary" @onclick="@(CancelEdit)">Cancel</button>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<button type="submit" class="btn btn-secondary" disabled="@(_saving)" @onclick="@(SaveEdit)">
|
||||
@if (!_saving)
|
||||
{
|
||||
<span>Save</span>
|
||||
}
|
||||
else
|
||||
{
|
||||
<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
|
||||
<span>Saving...</span>
|
||||
}
|
||||
</button>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
@if (!_editingMode)
|
||||
{
|
||||
if (_roles.IsNullOrEmpty())
|
||||
{
|
||||
<span class="text-center">No items</span>
|
||||
}
|
||||
else
|
||||
{
|
||||
<table class="table table-sm table-transparent">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">
|
||||
Person
|
||||
</th>
|
||||
<th scope="col">
|
||||
Role type
|
||||
</th>
|
||||
<th class="table-cell-fit" scope="col">
|
||||
Actions
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="table-group-divider">
|
||||
@foreach (Guid roleId in _roles.Keys)
|
||||
{
|
||||
<tr>
|
||||
<td class="align-middle">
|
||||
@(Persons[_roles[roleId].Data.PersonId].Name)
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
@(_roleTypes[_roles[roleId].Data.TypeId])
|
||||
</td>
|
||||
<td class="align-middle table-cell-fit">
|
||||
<div class="hstack gap-1">
|
||||
<button class="btn btn-outline-secondary btn-sm" type="button" disabled="@(!Id.HasValue || _roles[roleId].Deleting)" @onclick="@(() => ActivateEdit(roleId))"><i class="fas fa-edit"></i></button>
|
||||
<button class="btn btn-outline-danger btn-sm" type="button" disabled="@(!Id.HasValue || _roles[roleId].Deleting)" @onclick="@(() => Delete(roleId))">
|
||||
@if (_roles[roleId].Deleting)
|
||||
{
|
||||
<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
|
||||
}
|
||||
else
|
||||
{
|
||||
<i class="fa-solid fa-trash"></i>
|
||||
}
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
<EditForm Model="@(_editedModel)">
|
||||
<AntiforgeryToken/>
|
||||
<div class="container-grid">
|
||||
<div class="row form-group mb-1">
|
||||
<label for="creatorFormPerson" class="col-1 col-form-label">Media:</label>
|
||||
<div class="col">
|
||||
<Autocomplete ElementId="creatorFormPerson"
|
||||
TItem="PersonResponse"
|
||||
TValue="long"
|
||||
Data="@(Persons.Values)"
|
||||
TextField="@(item => item.Name)"
|
||||
ValueField="@(item => item.Id)"
|
||||
@bind-SelectedValue="@(_editedModel.PersonId)"
|
||||
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="creatorFormType" class="col-1 col-form-label">Type:</label>
|
||||
<div class="col">
|
||||
<InputSelect id="creatorFormType" 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>
|
||||
</EditForm>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<LoadingComponent Color="white"/>
|
||||
}
|
||||
</div>
|
||||
@@ -0,0 +1,147 @@
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using WatchIt.Common.Model.Media;
|
||||
using WatchIt.Common.Model.Persons;
|
||||
using WatchIt.Common.Model.Roles;
|
||||
using WatchIt.Website.Services.WebAPI.Media;
|
||||
using WatchIt.Website.Services.WebAPI.Persons;
|
||||
using WatchIt.Website.Services.WebAPI.Roles;
|
||||
|
||||
namespace WatchIt.Website.Components.MediaEditPage;
|
||||
|
||||
public partial class MediaRolesEditCreatorComponent : ComponentBase
|
||||
{
|
||||
#region SERVICES
|
||||
|
||||
[Inject] private IPersonsWebAPIService PersonsWebAPIService { get; set; } = default!;
|
||||
[Inject] private IMediaWebAPIService MediaWebAPIService { get; set; } = default!;
|
||||
[Inject] private IRolesWebAPIService RolesWebAPIService { get; set; } = default!;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PARAMETERS
|
||||
|
||||
[Parameter] public required long? Id { get; set; }
|
||||
[Parameter] public required Dictionary<long, PersonResponse> Persons { get; set; }
|
||||
[Parameter] public string Class { get; set; } = string.Empty;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region FIELDS
|
||||
|
||||
private bool _loaded;
|
||||
private string? _error;
|
||||
|
||||
private Dictionary<Guid, (CreatorRoleResponse Data, bool Deleting)> _roles = [];
|
||||
private Dictionary<short, string> _roleTypes = [];
|
||||
|
||||
|
||||
private Guid? _editedId;
|
||||
private ICreatorRoleMediaRequest? _editedModel;
|
||||
|
||||
private bool _editingMode;
|
||||
private bool _saving;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PUBLIC METHODS
|
||||
|
||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||
{
|
||||
if (firstRender)
|
||||
{
|
||||
List<Task> endTasks = new List<Task>();
|
||||
|
||||
// STEP 0
|
||||
if (Id.HasValue)
|
||||
{
|
||||
endTasks.AddRange(
|
||||
[
|
||||
MediaWebAPIService.GetMediaAllCreatorRoles(Id.Value, successAction: data => _roles = data.ToDictionary(x => x.Id, x => (x, false))),
|
||||
RolesWebAPIService.GetAllCreatorRoleTypes(successAction: data => _roleTypes = data.ToDictionary(x => x.Id, x => x.Name)),
|
||||
]);
|
||||
}
|
||||
|
||||
// END
|
||||
await Task.WhenAll(endTasks);
|
||||
|
||||
_loaded = true;
|
||||
StateHasChanged();
|
||||
}
|
||||
}
|
||||
|
||||
private void CancelEdit()
|
||||
{
|
||||
_error = null;
|
||||
_editingMode = false;
|
||||
}
|
||||
|
||||
private async Task SaveEdit()
|
||||
{
|
||||
void SuccessPost(CreatorRoleResponse data)
|
||||
{
|
||||
_roles[data.Id] = (data, false);
|
||||
|
||||
_saving = false;
|
||||
_editingMode = false;
|
||||
}
|
||||
|
||||
void SuccessPut()
|
||||
{
|
||||
CreatorRoleResponse temp = _roles[_editedId!.Value].Data;
|
||||
temp.PersonId = _editedModel.PersonId;
|
||||
temp.TypeId = _editedModel.TypeId;
|
||||
|
||||
_roles[_editedId!.Value] = (temp, false);
|
||||
|
||||
_saving = false;
|
||||
_editingMode = false;
|
||||
}
|
||||
|
||||
void BadRequest(IDictionary<string, string[]> errors)
|
||||
{
|
||||
_error = errors.SelectMany(x => x.Value).FirstOrDefault() ?? "Unknown error";
|
||||
_saving = false;
|
||||
}
|
||||
|
||||
void Unauthorized()
|
||||
{
|
||||
_error = "You do not have permission to do this";
|
||||
_saving = false;
|
||||
}
|
||||
|
||||
_error = null;
|
||||
_saving = true;
|
||||
if (_editedId.HasValue)
|
||||
{
|
||||
await RolesWebAPIService.PutCreatorRole(_editedId.Value, _editedModel as CreatorRoleUniversalRequest, SuccessPut, BadRequest, Unauthorized);
|
||||
}
|
||||
else
|
||||
{
|
||||
await MediaWebAPIService.PostMediaCreatorRole(Id!.Value, _editedModel as CreatorRoleMediaRequest, SuccessPost, BadRequest, Unauthorized);
|
||||
}
|
||||
}
|
||||
|
||||
private void ActivateEdit(Guid? id = null)
|
||||
{
|
||||
_editedId = id;
|
||||
_editedModel = id.HasValue ? new CreatorRoleUniversalRequest(_roles[id.Value].Data) : new CreatorRoleMediaRequest()
|
||||
{
|
||||
TypeId = _roleTypes.Keys.First()
|
||||
};
|
||||
_editingMode = true;
|
||||
}
|
||||
|
||||
private async Task Delete(Guid id)
|
||||
{
|
||||
_roles[id] = (_roles[id].Data, true);
|
||||
await RolesWebAPIService.DeleteCreatorRole(id, () => _roles.Remove(id));
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -45,7 +45,7 @@
|
||||
</InputSelect>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="row mt-2">
|
||||
<div class="col align-self-center">
|
||||
@if (!string.IsNullOrWhiteSpace(_error))
|
||||
{
|
||||
|
||||
@@ -0,0 +1,161 @@
|
||||
@using Blazorise.Extensions
|
||||
@using WatchIt.Common.Model.Roles
|
||||
@using Blazorise.Components
|
||||
|
||||
|
||||
|
||||
<div class="rounded-3 panel panel-regular p-3 @(Class)">
|
||||
@if (_loaded)
|
||||
{
|
||||
<div class="vstack gap-3">
|
||||
<div class="container-grid">
|
||||
<div class="row gx-2">
|
||||
<div class="col align-self-center">
|
||||
<h4 class="m-0"><strong>Actor roles</strong></h4>
|
||||
</div>
|
||||
@if (!_editingMode)
|
||||
{
|
||||
<div class="col-auto">
|
||||
<button type="button" class="btn btn-secondary" disabled="@(!Id.HasValue)" @onclick="@(() => ActivateEdit())">Add</button>
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(_error))
|
||||
{
|
||||
<div class="col-auto align-self-center">
|
||||
<span class="text-danger">@(_error)</span>
|
||||
</div>
|
||||
}
|
||||
<div class="col-auto">
|
||||
<button type="button" class="btn btn-secondary" @onclick="@(CancelEdit)">Cancel</button>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<button type="submit" class="btn btn-secondary" disabled="@(_saving)" @onclick="@(SaveEdit)">
|
||||
@if (!_saving)
|
||||
{
|
||||
<span>Save</span>
|
||||
}
|
||||
else
|
||||
{
|
||||
<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
|
||||
<span>Saving...</span>
|
||||
}
|
||||
</button>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
@if (!_editingMode)
|
||||
{
|
||||
if (_roles.IsNullOrEmpty())
|
||||
{
|
||||
<span class="text-center">No items</span>
|
||||
}
|
||||
else
|
||||
{
|
||||
<table class="table table-sm table-transparent">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">
|
||||
Media name
|
||||
</th>
|
||||
<th scope="col">
|
||||
Media type
|
||||
</th>
|
||||
<th scope="col">
|
||||
Role type
|
||||
</th>
|
||||
<th scope="col">
|
||||
Role name
|
||||
</th>
|
||||
<th class="table-cell-fit" scope="col">
|
||||
Actions
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="table-group-divider">
|
||||
@foreach (Guid roleId in _roles.Keys)
|
||||
{
|
||||
<tr>
|
||||
<td class="align-middle">
|
||||
@(Media[_roles[roleId].Data.MediaId].Title)@(Media[_roles[roleId].Data.MediaId].ReleaseDate.HasValue ? $" ({Media[_roles[roleId].Data.MediaId].ReleaseDate!.Value.Year})" : string.Empty)
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
@(Media[_roles[roleId].Data.MediaId].Type == MediaType.Movie ? $"Movie" : "TV Series")
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
@(_roleTypes[_roles[roleId].Data.TypeId])
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
@(_roles[roleId].Data.Name)
|
||||
</td>
|
||||
<td class="align-middle table-cell-fit">
|
||||
<div class="hstack gap-1">
|
||||
<button class="btn btn-outline-secondary btn-sm" type="button" disabled="@(!Id.HasValue || _roles[roleId].Deleting)" @onclick="@(() => ActivateEdit(roleId))"><i class="fas fa-edit"></i></button>
|
||||
<button class="btn btn-outline-danger btn-sm" type="button" disabled="@(!Id.HasValue || _roles[roleId].Deleting)" @onclick="@(() => Delete(roleId))">
|
||||
@if (_roles[roleId].Deleting)
|
||||
{
|
||||
<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
|
||||
}
|
||||
else
|
||||
{
|
||||
<i class="fa-solid fa-trash"></i>
|
||||
}
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
}
|
||||
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>
|
||||
}
|
||||
else
|
||||
{
|
||||
<LoadingComponent Color="white"/>
|
||||
}
|
||||
</div>
|
||||
@@ -0,0 +1,150 @@
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using WatchIt.Common.Model.Media;
|
||||
using WatchIt.Common.Model.Roles;
|
||||
using WatchIt.Website.Services.WebAPI.Media;
|
||||
using WatchIt.Website.Services.WebAPI.Persons;
|
||||
using WatchIt.Website.Services.WebAPI.Roles;
|
||||
|
||||
namespace WatchIt.Website.Components.PersonEditPage;
|
||||
|
||||
public partial class PersonRolesEditActorComponent : ComponentBase
|
||||
{
|
||||
#region SERVICES
|
||||
|
||||
[Inject] private IPersonsWebAPIService PersonsWebAPIService { get; set; } = default!;
|
||||
[Inject] private IMediaWebAPIService MediaWebAPIService { get; set; } = default!;
|
||||
[Inject] private IRolesWebAPIService RolesWebAPIService { get; set; } = default!;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PARAMETERS
|
||||
|
||||
[Parameter] public required long? Id { get; set; }
|
||||
[Parameter] public required Dictionary<long, MediaResponse> Media { get; set; }
|
||||
[Parameter] public string Class { get; set; } = string.Empty;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region FIELDS
|
||||
|
||||
private bool _loaded;
|
||||
private string? _error;
|
||||
|
||||
private Dictionary<Guid, (ActorRoleResponse Data, bool Deleting)> _roles = [];
|
||||
private Dictionary<short, string> _roleTypes = [];
|
||||
|
||||
|
||||
private Guid? _editedId;
|
||||
private IActorRolePersonRequest? _editedModel;
|
||||
|
||||
private bool _editingMode;
|
||||
private bool _saving;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PUBLIC METHODS
|
||||
|
||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||
{
|
||||
if (firstRender)
|
||||
{
|
||||
List<Task> endTasks = new List<Task>();
|
||||
|
||||
// STEP 0
|
||||
if (Id.HasValue)
|
||||
{
|
||||
endTasks.AddRange(
|
||||
[
|
||||
PersonsWebAPIService.GetPersonAllActorRoles(Id.Value, successAction: data => _roles = data.ToDictionary(x => x.Id, x => (x, false))),
|
||||
RolesWebAPIService.GetAllActorRoleTypes(successAction: data => _roleTypes = data.ToDictionary(x => x.Id, x => x.Name)),
|
||||
]);
|
||||
}
|
||||
|
||||
// END
|
||||
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;
|
||||
StateHasChanged();
|
||||
}
|
||||
}
|
||||
|
||||
private void CancelEdit()
|
||||
{
|
||||
_error = null;
|
||||
_editingMode = false;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
void BadRequest(IDictionary<string, string[]> errors)
|
||||
{
|
||||
_error = errors.SelectMany(x => x.Value).FirstOrDefault() ?? "Unknown error";
|
||||
_saving = false;
|
||||
}
|
||||
|
||||
void Unauthorized()
|
||||
{
|
||||
_error = "You do not have permission to do this";
|
||||
_saving = false;
|
||||
}
|
||||
|
||||
_error = null;
|
||||
_saving = true;
|
||||
if (_editedId.HasValue)
|
||||
{
|
||||
await RolesWebAPIService.PutActorRole(_editedId.Value, _editedModel as ActorRoleUniversalRequest, SuccessPut, BadRequest, Unauthorized);
|
||||
}
|
||||
else
|
||||
{
|
||||
await PersonsWebAPIService.PostPersonActorRole(Id!.Value, _editedModel as ActorRolePersonRequest, SuccessPost, BadRequest, Unauthorized);
|
||||
}
|
||||
}
|
||||
|
||||
private void ActivateEdit(Guid? id = null)
|
||||
{
|
||||
_editedId = id;
|
||||
_editedModel = id.HasValue ? new ActorRoleUniversalRequest(_roles[id.Value].Data) : new ActorRolePersonRequest()
|
||||
{
|
||||
TypeId = _roleTypes.Keys.First()
|
||||
};
|
||||
_editingMode = true;
|
||||
}
|
||||
|
||||
private async Task Delete(Guid id)
|
||||
{
|
||||
_roles[id] = (_roles[id].Data, true);
|
||||
await RolesWebAPIService.DeleteActorRole(id, () => _roles.Remove(id));
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,148 @@
|
||||
@using Blazorise.Extensions
|
||||
@using Blazorise.Components
|
||||
|
||||
|
||||
|
||||
<div class="rounded-3 panel panel-regular p-3 @(Class)">
|
||||
@if (_loaded)
|
||||
{
|
||||
<div class="vstack gap-3">
|
||||
<div class="container-grid">
|
||||
<div class="row gx-2">
|
||||
<div class="col align-self-center">
|
||||
<h4 class="m-0"><strong>Creator roles</strong></h4>
|
||||
</div>
|
||||
@if (!_editingMode)
|
||||
{
|
||||
<div class="col-auto">
|
||||
<button type="button" class="btn btn-secondary" disabled="@(!Id.HasValue)" @onclick="@(() => ActivateEdit())">Add</button>
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(_error))
|
||||
{
|
||||
<div class="col-auto align-self-center">
|
||||
<span class="text-danger">@(_error)</span>
|
||||
</div>
|
||||
}
|
||||
<div class="col-auto">
|
||||
<button type="button" class="btn btn-secondary" @onclick="@(CancelEdit)">Cancel</button>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<button type="submit" class="btn btn-secondary" disabled="@(_saving)" @onclick="@(SaveEdit)">
|
||||
@if (!_saving)
|
||||
{
|
||||
<span>Save</span>
|
||||
}
|
||||
else
|
||||
{
|
||||
<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
|
||||
<span>Saving...</span>
|
||||
}
|
||||
</button>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
@if (!_editingMode)
|
||||
{
|
||||
if (_roles.IsNullOrEmpty())
|
||||
{
|
||||
<span class="text-center">No items</span>
|
||||
}
|
||||
else
|
||||
{
|
||||
<table class="table table-sm table-transparent">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">
|
||||
Media name
|
||||
</th>
|
||||
<th scope="col">
|
||||
Media type
|
||||
</th>
|
||||
<th scope="col">
|
||||
Role type
|
||||
</th>
|
||||
<th class="table-cell-fit" scope="col">
|
||||
Actions
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="table-group-divider">
|
||||
@foreach (Guid roleId in _roles.Keys)
|
||||
{
|
||||
<tr>
|
||||
<td class="align-middle">
|
||||
@(Media[_roles[roleId].Data.MediaId].Title)@(Media[_roles[roleId].Data.MediaId].ReleaseDate.HasValue ? $" ({Media[_roles[roleId].Data.MediaId].ReleaseDate!.Value.Year})" : string.Empty)
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
@(Media[_roles[roleId].Data.MediaId].Type == MediaType.Movie ? $"Movie" : "TV Series")
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
@(_roleTypes[_roles[roleId].Data.TypeId])
|
||||
</td>
|
||||
<td class="align-middle table-cell-fit">
|
||||
<div class="hstack gap-1">
|
||||
<button class="btn btn-outline-secondary btn-sm" type="button" disabled="@(!Id.HasValue || _roles[roleId].Deleting)" @onclick="@(() => ActivateEdit(roleId))"><i class="fas fa-edit"></i></button>
|
||||
<button class="btn btn-outline-danger btn-sm" type="button" disabled="@(!Id.HasValue || _roles[roleId].Deleting)" @onclick="@(() => Delete(roleId))">
|
||||
@if (_roles[roleId].Deleting)
|
||||
{
|
||||
<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
|
||||
}
|
||||
else
|
||||
{
|
||||
<i class="fa-solid fa-trash"></i>
|
||||
}
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
<EditForm Model="@(_editedModel)">
|
||||
<AntiforgeryToken/>
|
||||
<div class="container-grid">
|
||||
<div class="row form-group mb-1">
|
||||
<label for="creatorFormMedia" class="col-1 col-form-label">Media:</label>
|
||||
<div class="col">
|
||||
<Autocomplete ElementId="creatorFormMedia"
|
||||
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="creatorFormType" class="col-1 col-form-label">Type:</label>
|
||||
<div class="col">
|
||||
<InputSelect id="creatorFormType" 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>
|
||||
</EditForm>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<LoadingComponent Color="white"/>
|
||||
}
|
||||
</div>
|
||||
@@ -0,0 +1,149 @@
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using WatchIt.Common.Model.Media;
|
||||
using WatchIt.Common.Model.Roles;
|
||||
using WatchIt.Website.Services.WebAPI.Media;
|
||||
using WatchIt.Website.Services.WebAPI.Persons;
|
||||
using WatchIt.Website.Services.WebAPI.Roles;
|
||||
|
||||
namespace WatchIt.Website.Components.PersonEditPage;
|
||||
|
||||
public partial class PersonRolesEditCreatorComponent : ComponentBase
|
||||
{
|
||||
#region SERVICES
|
||||
|
||||
[Inject] private IPersonsWebAPIService PersonsWebAPIService { get; set; } = default!;
|
||||
[Inject] private IMediaWebAPIService MediaWebAPIService { get; set; } = default!;
|
||||
[Inject] private IRolesWebAPIService RolesWebAPIService { get; set; } = default!;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PARAMETERS
|
||||
|
||||
[Parameter] public required long? Id { get; set; }
|
||||
[Parameter] public required Dictionary<long, MediaResponse> Media { get; set; }
|
||||
[Parameter] public string Class { get; set; } = string.Empty;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region FIELDS
|
||||
|
||||
private bool _loaded;
|
||||
private string? _error;
|
||||
|
||||
private Dictionary<Guid, (CreatorRoleResponse Data, bool Deleting)> _roles = [];
|
||||
private Dictionary<short, string> _roleTypes = [];
|
||||
|
||||
|
||||
private Guid? _editedId;
|
||||
private ICreatorRolePersonRequest? _editedModel;
|
||||
|
||||
private bool _editingMode;
|
||||
private bool _saving;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PUBLIC METHODS
|
||||
|
||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||
{
|
||||
if (firstRender)
|
||||
{
|
||||
List<Task> endTasks = new List<Task>();
|
||||
|
||||
// STEP 0
|
||||
if (Id.HasValue)
|
||||
{
|
||||
endTasks.AddRange(
|
||||
[
|
||||
PersonsWebAPIService.GetPersonAllCreatorRoles(Id.Value, successAction: data => _roles = data.ToDictionary(x => x.Id, x => (x, false))),
|
||||
RolesWebAPIService.GetAllCreatorRoleTypes(successAction: data => _roleTypes = data.ToDictionary(x => x.Id, x => x.Name)),
|
||||
]);
|
||||
}
|
||||
|
||||
// END
|
||||
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;
|
||||
StateHasChanged();
|
||||
}
|
||||
}
|
||||
|
||||
private void CancelEdit()
|
||||
{
|
||||
_error = null;
|
||||
_editingMode = false;
|
||||
}
|
||||
|
||||
private async Task SaveEdit()
|
||||
{
|
||||
void SuccessPost(CreatorRoleResponse 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()
|
||||
{
|
||||
CreatorRoleResponse temp = _roles[_editedId!.Value].Data;
|
||||
temp.MediaId = _editedModel.MediaId;
|
||||
temp.TypeId = _editedModel.TypeId;
|
||||
|
||||
_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;
|
||||
}
|
||||
|
||||
void BadRequest(IDictionary<string, string[]> errors)
|
||||
{
|
||||
_error = errors.SelectMany(x => x.Value).FirstOrDefault() ?? "Unknown error";
|
||||
_saving = false;
|
||||
}
|
||||
|
||||
void Unauthorized()
|
||||
{
|
||||
_error = "You do not have permission to do this";
|
||||
_saving = false;
|
||||
}
|
||||
|
||||
_error = null;
|
||||
_saving = true;
|
||||
if (_editedId.HasValue)
|
||||
{
|
||||
await RolesWebAPIService.PutCreatorRole(_editedId.Value, _editedModel as CreatorRoleUniversalRequest, SuccessPut, BadRequest, Unauthorized);
|
||||
}
|
||||
else
|
||||
{
|
||||
await PersonsWebAPIService.PostPersonCreatorRole(Id!.Value, _editedModel as CreatorRolePersonRequest, SuccessPost, BadRequest, Unauthorized);
|
||||
}
|
||||
}
|
||||
|
||||
private void ActivateEdit(Guid? id = null)
|
||||
{
|
||||
_editedId = id;
|
||||
_editedModel = id.HasValue ? new CreatorRoleUniversalRequest(_roles[id.Value].Data) : new CreatorRolePersonRequest()
|
||||
{
|
||||
TypeId = _roleTypes.Keys.First()
|
||||
};
|
||||
_editingMode = true;
|
||||
}
|
||||
|
||||
private async Task Delete(Guid id)
|
||||
{
|
||||
_roles[id] = (_roles[id].Data, true);
|
||||
await RolesWebAPIService.DeleteCreatorRole(id, () => _roles.Remove(id));
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -51,7 +51,7 @@
|
||||
else
|
||||
{
|
||||
<div class="d-flex align-items-center justify-content-center h-100 content-width">
|
||||
<LoadingComponent/>
|
||||
<LoadingComponent Color="white"/>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
@@ -199,6 +199,18 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mt-3">
|
||||
<div class="col">
|
||||
<MediaRolesEditActorComponent Id="@(Id)"
|
||||
Persons="@(_persons)"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mt-3">
|
||||
<div class="col">
|
||||
<MediaRolesEditCreatorComponent Id="@(Id)"
|
||||
Persons="@(_persons)"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mt-3">
|
||||
<div class="col">
|
||||
<div class="rounded-3 panel panel-regular p-4">
|
||||
|
||||
@@ -3,12 +3,14 @@ using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.AspNetCore.Components.Forms;
|
||||
using WatchIt.Common.Model.Media;
|
||||
using WatchIt.Common.Model.Movies;
|
||||
using WatchIt.Common.Model.Persons;
|
||||
using WatchIt.Common.Model.Photos;
|
||||
using WatchIt.Common.Model.Series;
|
||||
using WatchIt.Website.Layout;
|
||||
using WatchIt.Website.Services.Utility.Authentication;
|
||||
using WatchIt.Website.Services.WebAPI.Media;
|
||||
using WatchIt.Website.Services.WebAPI.Movies;
|
||||
using WatchIt.Website.Services.WebAPI.Persons;
|
||||
using WatchIt.Website.Services.WebAPI.Photos;
|
||||
using WatchIt.Website.Services.WebAPI.Series;
|
||||
|
||||
@@ -24,6 +26,7 @@ public partial class MediaEditPage : ComponentBase
|
||||
[Inject] public IMoviesWebAPIService MoviesWebAPIService { get; set; } = default!;
|
||||
[Inject] public ISeriesWebAPIService SeriesWebAPIService { get; set; } = default!;
|
||||
[Inject] public IPhotosWebAPIService PhotosWebAPIService { get; set; } = default!;
|
||||
[Inject] public IPersonsWebAPIService PersonsWebAPIService { get; set; } = default!;
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -48,6 +51,8 @@ public partial class MediaEditPage : ComponentBase
|
||||
private User? _user;
|
||||
|
||||
private MediaResponse? _media;
|
||||
private Dictionary<long, PersonResponse> _persons;
|
||||
|
||||
private MovieRequest? _movieRequest;
|
||||
private SeriesRequest? _seriesRequest;
|
||||
private Media? _mediaRequest => _movieRequest is not null ? _movieRequest : _seriesRequest;
|
||||
@@ -107,6 +112,10 @@ public partial class MediaEditPage : ComponentBase
|
||||
[
|
||||
InitializeMedia()
|
||||
]);
|
||||
endTasks.AddRange(
|
||||
[
|
||||
PersonsWebAPIService.GetAllPersons(successAction: data => _persons = data.ToDictionary(x => x.Id, x => x))
|
||||
]);
|
||||
}
|
||||
|
||||
// STEP 2
|
||||
|
||||
@@ -59,6 +59,18 @@
|
||||
Class="h-100"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mt-3">
|
||||
<div class="col">
|
||||
<PersonRolesEditActorComponent Id="@(Id)"
|
||||
Media="@(_media)"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mt-3">
|
||||
<div class="col">
|
||||
<PersonRolesEditCreatorComponent Id="@(Id)"
|
||||
Media="@(_media)"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
else
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using WatchIt.Common.Model.Media;
|
||||
using WatchIt.Common.Model.Persons;
|
||||
using WatchIt.Website.Layout;
|
||||
using WatchIt.Website.Services.Utility.Authentication;
|
||||
using WatchIt.Website.Services.WebAPI.Media;
|
||||
using WatchIt.Website.Services.WebAPI.Persons;
|
||||
|
||||
namespace WatchIt.Website.Pages;
|
||||
@@ -13,6 +15,7 @@ public partial class PersonEditPage : ComponentBase
|
||||
[Inject] private NavigationManager NavigationManager { get; set; } = default!;
|
||||
[Inject] private IAuthenticationService AuthenticationService { get; set; } = default!;
|
||||
[Inject] private IPersonsWebAPIService PersonsWebAPIService { get; set; } = default!;
|
||||
[Inject] private IMediaWebAPIService MediaWebAPIService { get; set; } = default!;
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -36,6 +39,7 @@ public partial class PersonEditPage : ComponentBase
|
||||
private User? _user;
|
||||
|
||||
private PersonResponse? _person;
|
||||
private Dictionary<long, MediaResponse> _media = [];
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -53,7 +57,7 @@ public partial class PersonEditPage : ComponentBase
|
||||
// STEP 0
|
||||
step1Tasks.AddRange(
|
||||
[
|
||||
Task.Run(async () => _user = await AuthenticationService.GetUserAsync())
|
||||
Task.Run(async () => _user = await AuthenticationService.GetUserAsync()),
|
||||
]);
|
||||
|
||||
// STEP 1
|
||||
@@ -62,7 +66,8 @@ public partial class PersonEditPage : ComponentBase
|
||||
{
|
||||
endTasks.AddRange(
|
||||
[
|
||||
PersonsWebAPIService.GetPerson(Id.Value, data => _person = data, () => NavigationManager.NavigateTo("/person/new", true))
|
||||
PersonsWebAPIService.GetPerson(Id.Value, data => _person = data, () => NavigationManager.NavigateTo("/person/new", true)),
|
||||
MediaWebAPIService.GetAllMedia(successAction: data => _media = data.ToDictionary(x => x.Id, x => x)),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ using WatchIt.Website.Services.WebAPI.Media;
|
||||
using WatchIt.Website.Services.WebAPI.Movies;
|
||||
using WatchIt.Website.Services.WebAPI.Persons;
|
||||
using WatchIt.Website.Services.WebAPI.Photos;
|
||||
using WatchIt.Website.Services.WebAPI.Roles;
|
||||
using WatchIt.Website.Services.WebAPI.Series;
|
||||
|
||||
namespace WatchIt.Website;
|
||||
@@ -79,6 +80,7 @@ public static class Program
|
||||
builder.Services.AddSingleton<ISeriesWebAPIService, SeriesWebAPIService>();
|
||||
builder.Services.AddSingleton<IPhotosWebAPIService, PhotosWebAPIService>();
|
||||
builder.Services.AddSingleton<IPersonsWebAPIService, PersonsWebAPIService>();
|
||||
builder.Services.AddSingleton<IRolesWebAPIService, RolesWebAPIService>();
|
||||
|
||||
return builder;
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
<ProjectReference Include="..\WatchIt.Website.Services\WatchIt.Website.Services.WebAPI\WatchIt.Website.Services.WebAPI.Movies\WatchIt.Website.Services.WebAPI.Movies.csproj" />
|
||||
<ProjectReference Include="..\WatchIt.Website.Services\WatchIt.Website.Services.WebAPI\WatchIt.Website.Services.WebAPI.Persons\WatchIt.Website.Services.WebAPI.Persons.csproj" />
|
||||
<ProjectReference Include="..\WatchIt.Website.Services\WatchIt.Website.Services.WebAPI\WatchIt.Website.Services.WebAPI.Photos\WatchIt.Website.Services.WebAPI.Photos.csproj" />
|
||||
<ProjectReference Include="..\WatchIt.Website.Services\WatchIt.Website.Services.WebAPI\WatchIt.Website.Services.WebAPI.Roles\WatchIt.Website.Services.WebAPI.Roles.csproj" />
|
||||
<ProjectReference Include="..\WatchIt.Website.Services\WatchIt.Website.Services.WebAPI\WatchIt.Website.Services.WebAPI.Series\WatchIt.Website.Services.WebAPI.Series.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -46,6 +47,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Blazorise.Bootstrap5" Version="1.6.1" />
|
||||
<PackageReference Include="Blazorise.Components" Version="1.6.1" />
|
||||
<PackageReference Include="Blazorise.Icons.FontAwesome" Version="1.6.1" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
@using WatchIt.Website.Layout
|
||||
@using WatchIt.Website.Components
|
||||
@using WatchIt.Website.Components.PersonEditPage
|
||||
@using WatchIt.Website.Components.MediaEditPage
|
||||
@using WatchIt.Common.Model.Accounts
|
||||
@using WatchIt.Common.Model.Media
|
||||
@using WatchIt.Website.Services.Utility.Tokens
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
},
|
||||
"Media": {
|
||||
"Base": "/media",
|
||||
"GetAllMedia": "",
|
||||
"GetMedia": "/{0}",
|
||||
"GetMediaGenres": "/{0}/genres",
|
||||
"PostMediaGenre": "/{0}/genres/{1}",
|
||||
|
||||
@@ -42,7 +42,14 @@ body, html {
|
||||
-webkit-text-fill-color: transparent;
|
||||
}
|
||||
|
||||
.table-transparent {
|
||||
--bs-table-bg: transparent !important;
|
||||
}
|
||||
|
||||
.table td.table-cell-fit, .table th.table-cell-fit {
|
||||
white-space: nowrap;
|
||||
width: 1%;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user