Merge pull request #94 from mateuszskoczek/features/person_edit_page
Features/person edit page
This commit is contained in:
@@ -0,0 +1,22 @@
|
|||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using WatchIt.Common.Query;
|
||||||
|
|
||||||
|
namespace WatchIt.Common.Model.Genders;
|
||||||
|
|
||||||
|
public class GenderQueryParameters : QueryParameters<GenderResponse>
|
||||||
|
{
|
||||||
|
#region PROPERTIES
|
||||||
|
|
||||||
|
[FromQuery(Name = "name")]
|
||||||
|
public string? Name { get; set; }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#region PRIVATE METHODS
|
||||||
|
|
||||||
|
protected override bool IsMeetingConditions(GenderResponse item) => TestStringWithRegex(item.Name, Name);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
13
WatchIt.Common/WatchIt.Common.Model/Genders/GenderRequest.cs
Normal file
13
WatchIt.Common/WatchIt.Common.Model/Genders/GenderRequest.cs
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
namespace WatchIt.Common.Model.Genders;
|
||||||
|
|
||||||
|
public class GenderRequest : Gender
|
||||||
|
{
|
||||||
|
#region PUBLIC METHODS
|
||||||
|
|
||||||
|
public Database.Model.Common.Gender CreateGender() => new Database.Model.Common.Gender()
|
||||||
|
{
|
||||||
|
Name = Name
|
||||||
|
};
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
@@ -1,12 +1,20 @@
|
|||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
|
using WatchIt.Common.Query;
|
||||||
|
|
||||||
namespace WatchIt.Common.Model.Genders;
|
namespace WatchIt.Common.Model.Genders;
|
||||||
|
|
||||||
public class GenderResponse : Gender
|
public class GenderResponse : Gender, IQueryOrderable<GenderResponse>
|
||||||
{
|
{
|
||||||
#region PROPERTIES
|
#region PROPERTIES
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
public static IDictionary<string, Func<GenderResponse, IComparable>> OrderableProperties { get; } = new Dictionary<string, Func<GenderResponse, IComparable>>
|
||||||
|
{
|
||||||
|
{ "name", item => item.Name }
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
[JsonPropertyName("id")]
|
[JsonPropertyName("id")]
|
||||||
public required short? Id { get; set; }
|
public required short? Id { get; set; }
|
||||||
|
|
||||||
@@ -15,6 +23,9 @@ public class GenderResponse : Gender
|
|||||||
|
|
||||||
|
|
||||||
#region CONSTRUCTORS
|
#region CONSTRUCTORS
|
||||||
|
|
||||||
|
[JsonConstructor]
|
||||||
|
public GenderResponse() { }
|
||||||
|
|
||||||
[SetsRequiredMembers]
|
[SetsRequiredMembers]
|
||||||
public GenderResponse(Database.Model.Common.Gender gender)
|
public GenderResponse(Database.Model.Common.Gender gender)
|
||||||
|
|||||||
@@ -10,10 +10,10 @@ public class MediaPosterRequest : MediaPoster
|
|||||||
public MediaPosterRequest() {}
|
public MediaPosterRequest() {}
|
||||||
|
|
||||||
[SetsRequiredMembers]
|
[SetsRequiredMembers]
|
||||||
public MediaPosterRequest(MediaPosterResponse response)
|
public MediaPosterRequest(Picture image)
|
||||||
{
|
{
|
||||||
Image = response.Image;
|
Image = image.Image;
|
||||||
MimeType = response.MimeType;
|
MimeType = image.MimeType;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
namespace WatchIt.Common.Model.Persons;
|
||||||
|
|
||||||
|
public class PersonPhoto : Picture
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
using System.Diagnostics.CodeAnalysis;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
using WatchIt.Database.Model.Person;
|
||||||
|
|
||||||
|
namespace WatchIt.Common.Model.Persons;
|
||||||
|
|
||||||
|
public class PersonPhotoRequest : PersonPhoto
|
||||||
|
{
|
||||||
|
#region CONSTRUCTORS
|
||||||
|
|
||||||
|
[JsonConstructor]
|
||||||
|
public PersonPhotoRequest() {}
|
||||||
|
|
||||||
|
[SetsRequiredMembers]
|
||||||
|
public PersonPhotoRequest(Picture image)
|
||||||
|
{
|
||||||
|
Image = image.Image;
|
||||||
|
MimeType = image.MimeType;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#region PUBLIC METHODS
|
||||||
|
|
||||||
|
public PersonPhotoImage CreatePersonPhotoImage() => new PersonPhotoImage
|
||||||
|
{
|
||||||
|
Image = Image,
|
||||||
|
MimeType = MimeType,
|
||||||
|
};
|
||||||
|
|
||||||
|
public void UpdatePersonPhotoImage(PersonPhotoImage item)
|
||||||
|
{
|
||||||
|
item.Image = Image;
|
||||||
|
item.MimeType = MimeType;
|
||||||
|
item.UploadDate = DateTime.UtcNow;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
using System.Diagnostics.CodeAnalysis;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
using WatchIt.Database.Model.Person;
|
||||||
|
|
||||||
|
namespace WatchIt.Common.Model.Persons;
|
||||||
|
|
||||||
|
public class PersonPhotoResponse : PersonPhoto
|
||||||
|
{
|
||||||
|
#region PROPERTIES
|
||||||
|
|
||||||
|
[JsonPropertyName("id")]
|
||||||
|
public Guid Id { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("upload_date")]
|
||||||
|
public DateTime UploadDate { get; set; }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#region CONSTRUCTORS
|
||||||
|
|
||||||
|
[JsonConstructor]
|
||||||
|
public PersonPhotoResponse() {}
|
||||||
|
|
||||||
|
[SetsRequiredMembers]
|
||||||
|
public PersonPhotoResponse(PersonPhotoImage personPhotoImage)
|
||||||
|
{
|
||||||
|
Id = personPhotoImage.Id;
|
||||||
|
Image = personPhotoImage.Image;
|
||||||
|
MimeType = personPhotoImage.MimeType;
|
||||||
|
UploadDate = personPhotoImage.UploadDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
namespace WatchIt.Common.Model.Persons;
|
namespace WatchIt.Common.Model.Persons;
|
||||||
@@ -10,6 +11,29 @@ public class PersonRequest : Person
|
|||||||
public short? GenderId { get; set; }
|
public short? GenderId { get; set; }
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#region CONSTRUCTORS
|
||||||
|
|
||||||
|
[SetsRequiredMembers]
|
||||||
|
public PersonRequest()
|
||||||
|
{
|
||||||
|
Name = string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
[SetsRequiredMembers]
|
||||||
|
public PersonRequest(PersonResponse person)
|
||||||
|
{
|
||||||
|
Name = person.Name;
|
||||||
|
FullName = person.FullName;
|
||||||
|
Description = person.Description;
|
||||||
|
BirthDate = person.BirthDate;
|
||||||
|
DeathDate = person.DeathDate;
|
||||||
|
GenderId = person.Gender?.Id;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -40,6 +40,9 @@ public class PersonResponse : Person, IQueryOrderable<PersonResponse>
|
|||||||
|
|
||||||
#region CONSTRUCTORS
|
#region CONSTRUCTORS
|
||||||
|
|
||||||
|
[JsonConstructor]
|
||||||
|
public PersonResponse() { }
|
||||||
|
|
||||||
[SetsRequiredMembers]
|
[SetsRequiredMembers]
|
||||||
public PersonResponse(Database.Model.Person.Person person)
|
public PersonResponse(Database.Model.Person.Person person)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ using System.Text.Json.Serialization;
|
|||||||
|
|
||||||
namespace WatchIt.Common.Model;
|
namespace WatchIt.Common.Model;
|
||||||
|
|
||||||
public abstract class Picture
|
public class Picture
|
||||||
{
|
{
|
||||||
#region PROPERTIES
|
#region PROPERTIES
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,66 @@
|
|||||||
|
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using WatchIt.Common.Model.Genders;
|
||||||
|
using WatchIt.WebAPI.Services.Controllers.Genders;
|
||||||
|
|
||||||
|
namespace WatchIt.WebAPI.Controllers;
|
||||||
|
|
||||||
|
[ApiController]
|
||||||
|
[Route("genders")]
|
||||||
|
public class GendersController : ControllerBase
|
||||||
|
{
|
||||||
|
#region SERVICES
|
||||||
|
|
||||||
|
private readonly IGendersControllerService _gendersControllerService;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#region CONSTRUCTORS
|
||||||
|
|
||||||
|
public GendersController(IGendersControllerService gendersControllerService)
|
||||||
|
{
|
||||||
|
_gendersControllerService = gendersControllerService;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#region METHODS
|
||||||
|
|
||||||
|
#region Main
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
[AllowAnonymous]
|
||||||
|
[ProducesResponseType(typeof(IEnumerable<GenderResponse>), StatusCodes.Status200OK)]
|
||||||
|
public async Task<ActionResult> GetAllGenders(GenderQueryParameters query) => await _gendersControllerService.GetAllGenders(query);
|
||||||
|
|
||||||
|
[HttpGet("{id}")]
|
||||||
|
[AllowAnonymous]
|
||||||
|
[ProducesResponseType(typeof(GenderResponse), StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||||
|
public async Task<ActionResult> GetGender([FromRoute]short id) => await _gendersControllerService.GetGender(id);
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
|
||||||
|
[ProducesResponseType(typeof(GenderResponse), StatusCodes.Status201Created)]
|
||||||
|
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
|
||||||
|
[ProducesResponseType(typeof(void), StatusCodes.Status401Unauthorized)]
|
||||||
|
[ProducesResponseType(typeof(void), StatusCodes.Status403Forbidden)]
|
||||||
|
public async Task<ActionResult> PostGender([FromBody]GenderRequest body) => await _gendersControllerService.PostGender(body);
|
||||||
|
|
||||||
|
[HttpDelete("{id}")]
|
||||||
|
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
|
||||||
|
[ProducesResponseType(typeof(GenderResponse), StatusCodes.Status204NoContent)]
|
||||||
|
[ProducesResponseType(typeof(void), StatusCodes.Status401Unauthorized)]
|
||||||
|
[ProducesResponseType(typeof(void), StatusCodes.Status403Forbidden)]
|
||||||
|
public async Task<ActionResult> DeleteGender([FromRoute]short id) => await _gendersControllerService.DeleteGender(id);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
@@ -80,5 +80,31 @@ public class PersonsController : ControllerBase
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region Photo
|
||||||
|
|
||||||
|
[HttpGet("{id}/photo")]
|
||||||
|
[AllowAnonymous]
|
||||||
|
[ProducesResponseType(typeof(PersonPhotoResponse), StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||||
|
public async Task<ActionResult> GetPersonPhoto([FromRoute] long id) => await _personsControllerService.GetPersonPhoto(id);
|
||||||
|
|
||||||
|
[HttpPut("{id}/photo")]
|
||||||
|
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
|
||||||
|
[ProducesResponseType(typeof(PersonPhotoResponse), StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
|
||||||
|
[ProducesResponseType(typeof(void), StatusCodes.Status401Unauthorized)]
|
||||||
|
[ProducesResponseType(typeof(void), StatusCodes.Status403Forbidden)]
|
||||||
|
public async Task<ActionResult> PutPersonPhoto([FromRoute]long id, [FromBody]PersonPhotoRequest body) => await _personsControllerService.PutPersonPhoto(id, body);
|
||||||
|
|
||||||
|
[HttpDelete("{id}/photo")]
|
||||||
|
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
|
||||||
|
[ProducesResponseType(typeof(void), StatusCodes.Status204NoContent)]
|
||||||
|
[ProducesResponseType(typeof(void), StatusCodes.Status401Unauthorized)]
|
||||||
|
[ProducesResponseType(typeof(void), StatusCodes.Status403Forbidden)]
|
||||||
|
public async Task<ActionResult> DeletePersonPhoto([FromRoute]long id) => await _personsControllerService.DeletePersonPhoto(id);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
@@ -14,6 +14,7 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\..\WatchIt.Common\WatchIt.Common.Model\WatchIt.Common.Model.csproj" />
|
<ProjectReference Include="..\..\WatchIt.Common\WatchIt.Common.Model\WatchIt.Common.Model.csproj" />
|
||||||
<ProjectReference Include="..\WatchIt.WebAPI.Services\WatchIt.WebAPI.Services.Controllers\WatchIt.WebAPI.Services.Controllers.Accounts\WatchIt.WebAPI.Services.Controllers.Accounts.csproj" />
|
<ProjectReference Include="..\WatchIt.WebAPI.Services\WatchIt.WebAPI.Services.Controllers\WatchIt.WebAPI.Services.Controllers.Accounts\WatchIt.WebAPI.Services.Controllers.Accounts.csproj" />
|
||||||
|
<ProjectReference Include="..\WatchIt.WebAPI.Services\WatchIt.WebAPI.Services.Controllers\WatchIt.WebAPI.Services.Controllers.Genders\WatchIt.WebAPI.Services.Controllers.Genders.csproj" />
|
||||||
<ProjectReference Include="..\WatchIt.WebAPI.Services\WatchIt.WebAPI.Services.Controllers\WatchIt.WebAPI.Services.Controllers.Genres\WatchIt.WebAPI.Services.Controllers.Genres.csproj" />
|
<ProjectReference Include="..\WatchIt.WebAPI.Services\WatchIt.WebAPI.Services.Controllers\WatchIt.WebAPI.Services.Controllers.Genres\WatchIt.WebAPI.Services.Controllers.Genres.csproj" />
|
||||||
<ProjectReference Include="..\WatchIt.WebAPI.Services\WatchIt.WebAPI.Services.Controllers\WatchIt.WebAPI.Services.Controllers.Media\WatchIt.WebAPI.Services.Controllers.Media.csproj" />
|
<ProjectReference Include="..\WatchIt.WebAPI.Services\WatchIt.WebAPI.Services.Controllers\WatchIt.WebAPI.Services.Controllers.Media\WatchIt.WebAPI.Services.Controllers.Media.csproj" />
|
||||||
<ProjectReference Include="..\WatchIt.WebAPI.Services\WatchIt.WebAPI.Services.Controllers\WatchIt.WebAPI.Services.Controllers.Movies\WatchIt.WebAPI.Services.Controllers.Movies.csproj" />
|
<ProjectReference Include="..\WatchIt.WebAPI.Services\WatchIt.WebAPI.Services.Controllers\WatchIt.WebAPI.Services.Controllers.Movies\WatchIt.WebAPI.Services.Controllers.Movies.csproj" />
|
||||||
|
|||||||
@@ -0,0 +1,93 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using WatchIt.Common.Model.Genders;
|
||||||
|
using WatchIt.Database;
|
||||||
|
using WatchIt.Database.Model.Common;
|
||||||
|
using WatchIt.WebAPI.Services.Controllers.Common;
|
||||||
|
using WatchIt.WebAPI.Services.Utility.User;
|
||||||
|
using Gender = WatchIt.Database.Model.Common.Gender;
|
||||||
|
|
||||||
|
namespace WatchIt.WebAPI.Services.Controllers.Genders;
|
||||||
|
|
||||||
|
public class GendersControllerService : IGendersControllerService
|
||||||
|
{
|
||||||
|
#region SERVICES
|
||||||
|
|
||||||
|
private readonly DatabaseContext _database;
|
||||||
|
private readonly IUserService _userService;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#region CONSTRUCTORS
|
||||||
|
|
||||||
|
public GendersControllerService(DatabaseContext database, IUserService userService)
|
||||||
|
{
|
||||||
|
_database = database;
|
||||||
|
_userService = userService;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#region PUBLIC METHODS
|
||||||
|
|
||||||
|
public async Task<RequestResult> GetAllGenders(GenderQueryParameters query)
|
||||||
|
{
|
||||||
|
IEnumerable<Gender> rawData = await _database.Genders.ToListAsync();
|
||||||
|
IEnumerable<GenderResponse> data = rawData.Select(x => new GenderResponse(x));
|
||||||
|
data = query.PrepareData(data);
|
||||||
|
return RequestResult.Ok(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<RequestResult> GetGender(short id)
|
||||||
|
{
|
||||||
|
Gender? item = await _database.Genders.FirstOrDefaultAsync(x => x.Id == id);
|
||||||
|
if (item is null)
|
||||||
|
{
|
||||||
|
return RequestResult.NotFound();
|
||||||
|
}
|
||||||
|
|
||||||
|
GenderResponse data = new GenderResponse(item);
|
||||||
|
return RequestResult.Ok(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<RequestResult> PostGender(GenderRequest data)
|
||||||
|
{
|
||||||
|
UserValidator validator = _userService.GetValidator().MustBeAdmin();
|
||||||
|
if (!validator.IsValid)
|
||||||
|
{
|
||||||
|
return RequestResult.Forbidden();
|
||||||
|
}
|
||||||
|
|
||||||
|
Gender item = data.CreateGender();
|
||||||
|
await _database.Genders.AddAsync(item);
|
||||||
|
await _database.SaveChangesAsync();
|
||||||
|
|
||||||
|
return RequestResult.Created($"genres/{item.Id}", new GenderResponse(item));
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<RequestResult> DeleteGender(short id)
|
||||||
|
{
|
||||||
|
UserValidator validator = _userService.GetValidator().MustBeAdmin();
|
||||||
|
if (!validator.IsValid)
|
||||||
|
{
|
||||||
|
return RequestResult.Forbidden();
|
||||||
|
}
|
||||||
|
|
||||||
|
Gender? item = await _database.Genders.FirstOrDefaultAsync(x => x.Id == id);
|
||||||
|
if (item is null)
|
||||||
|
{
|
||||||
|
return RequestResult.NoContent();
|
||||||
|
}
|
||||||
|
|
||||||
|
_database.Genders.Attach(item);
|
||||||
|
_database.Genders.Remove(item);
|
||||||
|
await _database.SaveChangesAsync();
|
||||||
|
|
||||||
|
return RequestResult.NoContent();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
using WatchIt.Common.Model.Genders;
|
||||||
|
using WatchIt.WebAPI.Services.Controllers.Common;
|
||||||
|
|
||||||
|
namespace WatchIt.WebAPI.Services.Controllers.Genders;
|
||||||
|
|
||||||
|
public interface IGendersControllerService
|
||||||
|
{
|
||||||
|
Task<RequestResult> GetAllGenders(GenderQueryParameters query);
|
||||||
|
Task<RequestResult> GetGender(short id);
|
||||||
|
Task<RequestResult> PostGender(GenderRequest data);
|
||||||
|
Task<RequestResult> DeleteGender(short id);
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\..\..\..\WatchIt.Common\WatchIt.Common.Model\WatchIt.Common.Model.csproj" />
|
||||||
|
<ProjectReference Include="..\..\..\..\WatchIt.Database\WatchIt.Database\WatchIt.Database.csproj" />
|
||||||
|
<ProjectReference Include="..\..\WatchIt.WebAPI.Services.Utility\WatchIt.WebAPI.Services.Utility.User\WatchIt.WebAPI.Services.Utility.User.csproj" />
|
||||||
|
<ProjectReference Include="..\WatchIt.WebAPI.Services.Controllers.Common\WatchIt.WebAPI.Services.Controllers.Common.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
@@ -10,5 +10,10 @@ public interface IPersonsControllerService
|
|||||||
Task<RequestResult> PostPerson(PersonRequest data);
|
Task<RequestResult> PostPerson(PersonRequest data);
|
||||||
Task<RequestResult> PutPerson(long id, PersonRequest data);
|
Task<RequestResult> PutPerson(long id, PersonRequest data);
|
||||||
Task<RequestResult> DeletePerson(long id);
|
Task<RequestResult> DeletePerson(long id);
|
||||||
|
|
||||||
Task<RequestResult> GetPersonsViewRank(int first, int days);
|
Task<RequestResult> GetPersonsViewRank(int first, int days);
|
||||||
|
|
||||||
|
Task<RequestResult> GetPersonPhoto(long id);
|
||||||
|
Task<RequestResult> PutPersonPhoto(long id, PersonPhotoRequest data);
|
||||||
|
Task<RequestResult> DeletePersonPhoto(long id);
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using WatchIt.Common.Model.Persons;
|
using WatchIt.Common.Model.Persons;
|
||||||
using WatchIt.Database;
|
using WatchIt.Database;
|
||||||
|
using WatchIt.Database.Model.Person;
|
||||||
using WatchIt.WebAPI.Services.Controllers.Common;
|
using WatchIt.WebAPI.Services.Controllers.Common;
|
||||||
using WatchIt.WebAPI.Services.Utility.User;
|
using WatchIt.WebAPI.Services.Utility.User;
|
||||||
using Person = WatchIt.Database.Model.Person.Person;
|
using Person = WatchIt.Database.Model.Person.Person;
|
||||||
@@ -142,5 +143,80 @@ public class PersonsControllerService : IPersonsControllerService
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region Photo
|
||||||
|
|
||||||
|
public async Task<RequestResult> GetPersonPhoto(long id)
|
||||||
|
{
|
||||||
|
Person? person = await _database.Persons.FirstOrDefaultAsync(x => x.Id == id);
|
||||||
|
if (person is null)
|
||||||
|
{
|
||||||
|
return RequestResult.BadRequest();
|
||||||
|
}
|
||||||
|
|
||||||
|
PersonPhotoImage? photo = person.PersonPhoto;
|
||||||
|
if (photo is null)
|
||||||
|
{
|
||||||
|
return RequestResult.NotFound();
|
||||||
|
}
|
||||||
|
|
||||||
|
PersonPhotoResponse data = new PersonPhotoResponse(photo);
|
||||||
|
return RequestResult.Ok(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<RequestResult> PutPersonPhoto(long id, PersonPhotoRequest data)
|
||||||
|
{
|
||||||
|
UserValidator validator = _userService.GetValidator().MustBeAdmin();
|
||||||
|
if (!validator.IsValid)
|
||||||
|
{
|
||||||
|
return RequestResult.Forbidden();
|
||||||
|
}
|
||||||
|
|
||||||
|
Person? person = await _database.Persons.FirstOrDefaultAsync(x => x.Id == id);
|
||||||
|
if (person is null)
|
||||||
|
{
|
||||||
|
return RequestResult.BadRequest();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (person.PersonPhoto is null)
|
||||||
|
{
|
||||||
|
PersonPhotoImage image = data.CreatePersonPhotoImage();
|
||||||
|
await _database.PersonPhotoImages.AddAsync(image);
|
||||||
|
await _database.SaveChangesAsync();
|
||||||
|
|
||||||
|
person.PersonPhotoId = image.Id;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
data.UpdatePersonPhotoImage(person.PersonPhoto);
|
||||||
|
}
|
||||||
|
|
||||||
|
await _database.SaveChangesAsync();
|
||||||
|
|
||||||
|
PersonPhotoResponse returnData = new PersonPhotoResponse(person.PersonPhoto);
|
||||||
|
return RequestResult.Ok(returnData);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<RequestResult> DeletePersonPhoto(long id)
|
||||||
|
{
|
||||||
|
UserValidator validator = _userService.GetValidator().MustBeAdmin();
|
||||||
|
if (!validator.IsValid)
|
||||||
|
{
|
||||||
|
return RequestResult.Forbidden();
|
||||||
|
}
|
||||||
|
|
||||||
|
Person? person = await _database.Persons.FirstOrDefaultAsync(x => x.Id == id);
|
||||||
|
|
||||||
|
if (person?.PersonPhoto != null)
|
||||||
|
{
|
||||||
|
_database.PersonPhotoImages.Attach(person.PersonPhoto);
|
||||||
|
_database.PersonPhotoImages.Remove(person.PersonPhoto);
|
||||||
|
await _database.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
return RequestResult.NoContent();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,19 @@
|
|||||||
using FluentValidation;
|
using FluentValidation;
|
||||||
using WatchIt.Common.Model.Persons;
|
using WatchIt.Common.Model.Persons;
|
||||||
|
using WatchIt.Database;
|
||||||
|
|
||||||
namespace WatchIt.WebAPI.Validators.Persons;
|
namespace WatchIt.WebAPI.Validators.Persons;
|
||||||
|
|
||||||
public class PersonRequestValidator : AbstractValidator<PersonRequest>
|
public class PersonRequestValidator : AbstractValidator<PersonRequest>
|
||||||
{
|
{
|
||||||
|
public PersonRequestValidator(DatabaseContext database)
|
||||||
|
{
|
||||||
|
RuleFor(x => x.Name).NotEmpty().MaximumLength(100);
|
||||||
|
RuleFor(x => x.FullName).MaximumLength(200);
|
||||||
|
RuleFor(x => x.Description).MaximumLength(1000);
|
||||||
|
When(x => x.GenderId.HasValue, () =>
|
||||||
|
{
|
||||||
|
RuleFor(x => x.GenderId!.Value).MustBeIn(database.Genders.Select(g => g.Id));
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -10,6 +10,7 @@ using Microsoft.IdentityModel.JsonWebTokens;
|
|||||||
using Microsoft.IdentityModel.Tokens;
|
using Microsoft.IdentityModel.Tokens;
|
||||||
using WatchIt.Database;
|
using WatchIt.Database;
|
||||||
using WatchIt.WebAPI.Services.Controllers.Accounts;
|
using WatchIt.WebAPI.Services.Controllers.Accounts;
|
||||||
|
using WatchIt.WebAPI.Services.Controllers.Genders;
|
||||||
using WatchIt.WebAPI.Services.Controllers.Genres;
|
using WatchIt.WebAPI.Services.Controllers.Genres;
|
||||||
using WatchIt.WebAPI.Services.Controllers.Media;
|
using WatchIt.WebAPI.Services.Controllers.Media;
|
||||||
using WatchIt.WebAPI.Services.Controllers.Movies;
|
using WatchIt.WebAPI.Services.Controllers.Movies;
|
||||||
@@ -154,6 +155,7 @@ public static class Program
|
|||||||
|
|
||||||
// Controller
|
// Controller
|
||||||
builder.Services.AddTransient<IAccountsControllerService, AccountsControllerService>();
|
builder.Services.AddTransient<IAccountsControllerService, AccountsControllerService>();
|
||||||
|
builder.Services.AddTransient<IGendersControllerService, GendersControllerService>();
|
||||||
builder.Services.AddTransient<IGenresControllerService, GenresControllerService>();
|
builder.Services.AddTransient<IGenresControllerService, GenresControllerService>();
|
||||||
builder.Services.AddTransient<IMoviesControllerService, MoviesControllerService>();
|
builder.Services.AddTransient<IMoviesControllerService, MoviesControllerService>();
|
||||||
builder.Services.AddTransient<IMediaControllerService, MediaControllerService>();
|
builder.Services.AddTransient<IMediaControllerService, MediaControllerService>();
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ public class Endpoints
|
|||||||
{
|
{
|
||||||
public string Base { get; set; }
|
public string Base { get; set; }
|
||||||
public Accounts Accounts { get; set; }
|
public Accounts Accounts { get; set; }
|
||||||
|
public Genders Genders { get; set; }
|
||||||
public Genres Genres { get; set; }
|
public Genres Genres { get; set; }
|
||||||
public Media Media { get; set; }
|
public Media Media { get; set; }
|
||||||
public Movies Movies { get; set; }
|
public Movies Movies { get; set; }
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
namespace WatchIt.Website.Services.Utility.Configuration.Model;
|
||||||
|
|
||||||
|
public class Genders
|
||||||
|
{
|
||||||
|
public string Base { get; set; }
|
||||||
|
public string GetAllGenders { get; set; }
|
||||||
|
public string GetGender { get; set; }
|
||||||
|
public string PostGender { get; set; }
|
||||||
|
public string DeleteGender { get; set; }
|
||||||
|
}
|
||||||
@@ -9,4 +9,7 @@ public class Persons
|
|||||||
public string PutPerson { get; set; }
|
public string PutPerson { get; set; }
|
||||||
public string DeletePerson { get; set; }
|
public string DeletePerson { get; set; }
|
||||||
public string GetPersonsViewRank { get; set; }
|
public string GetPersonsViewRank { get; set; }
|
||||||
|
public string GetPersonPhoto { get; set; }
|
||||||
|
public string PutPersonPhoto { get; set; }
|
||||||
|
public string DeletePersonPhoto { get; set; }
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,98 @@
|
|||||||
|
using WatchIt.Common.Model.Genders;
|
||||||
|
using WatchIt.Common.Services.HttpClient;
|
||||||
|
using WatchIt.Website.Services.Utility.Configuration;
|
||||||
|
using WatchIt.Website.Services.WebAPI.Common;
|
||||||
|
|
||||||
|
namespace WatchIt.Website.Services.WebAPI.Genders;
|
||||||
|
|
||||||
|
public class GendersWebAPIService : BaseWebAPIService, IGendersWebAPIService
|
||||||
|
{
|
||||||
|
#region SERVICES
|
||||||
|
|
||||||
|
private IHttpClientService _httpClientService;
|
||||||
|
private IConfigurationService _configurationService;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#region CONSTRUCTORS
|
||||||
|
|
||||||
|
public GendersWebAPIService(IHttpClientService httpClientService, IConfigurationService configurationService) : base(configurationService)
|
||||||
|
{
|
||||||
|
_httpClientService = httpClientService;
|
||||||
|
_configurationService = configurationService;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#region PUBLIC METHODS
|
||||||
|
|
||||||
|
#region Main
|
||||||
|
|
||||||
|
public async Task GetAllGenders(GenderQueryParameters? query = null, Action<IEnumerable<GenderResponse>>? successAction = null)
|
||||||
|
{
|
||||||
|
string url = GetUrl(EndpointsConfiguration.Genders.GetAllGenders);
|
||||||
|
|
||||||
|
HttpRequest request = new HttpRequest(HttpMethodType.Get, url);
|
||||||
|
request.Query = query;
|
||||||
|
|
||||||
|
HttpResponse response = await _httpClientService.SendRequestAsync(request);
|
||||||
|
response.RegisterActionFor2XXSuccess(successAction)
|
||||||
|
.ExecuteAction();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task GetGender(long id, Action<GenderResponse>? successAction = null, Action? notFoundAction = null)
|
||||||
|
{
|
||||||
|
string url = GetUrl(EndpointsConfiguration.Genders.GetGender, id);
|
||||||
|
|
||||||
|
HttpRequest request = new HttpRequest(HttpMethodType.Get, url);
|
||||||
|
|
||||||
|
HttpResponse response = await _httpClientService.SendRequestAsync(request);
|
||||||
|
response.RegisterActionFor2XXSuccess(successAction)
|
||||||
|
.RegisterActionFor404NotFound(notFoundAction)
|
||||||
|
.ExecuteAction();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task PostGender(GenderRequest data, Action<GenderResponse>? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null)
|
||||||
|
{
|
||||||
|
string url = GetUrl(EndpointsConfiguration.Genders.PostGender);
|
||||||
|
|
||||||
|
HttpRequest request = new HttpRequest(HttpMethodType.Post, url);
|
||||||
|
request.Body = data;
|
||||||
|
|
||||||
|
HttpResponse response = await _httpClientService.SendRequestAsync(request);
|
||||||
|
response.RegisterActionFor2XXSuccess(successAction)
|
||||||
|
.RegisterActionFor400BadRequest(badRequestAction)
|
||||||
|
.RegisterActionFor401Unauthorized(unauthorizedAction)
|
||||||
|
.RegisterActionFor403Forbidden(forbiddenAction)
|
||||||
|
.ExecuteAction();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task DeleteGender(long id, Action? successAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null)
|
||||||
|
{
|
||||||
|
string url = GetUrl(EndpointsConfiguration.Genders.DeleteGender, id);
|
||||||
|
|
||||||
|
HttpRequest request = new HttpRequest(HttpMethodType.Delete, url);
|
||||||
|
|
||||||
|
HttpResponse response = await _httpClientService.SendRequestAsync(request);
|
||||||
|
response.RegisterActionFor2XXSuccess(successAction)
|
||||||
|
.RegisterActionFor401Unauthorized(unauthorizedAction)
|
||||||
|
.RegisterActionFor403Forbidden(forbiddenAction)
|
||||||
|
.ExecuteAction();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#region PRIVATE METHODS
|
||||||
|
|
||||||
|
protected override string GetServiceBase() => EndpointsConfiguration.Genders.Base;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
using WatchIt.Common.Model.Genders;
|
||||||
|
|
||||||
|
namespace WatchIt.Website.Services.WebAPI.Genders;
|
||||||
|
|
||||||
|
public interface IGendersWebAPIService
|
||||||
|
{
|
||||||
|
Task GetAllGenders(GenderQueryParameters? query = null, Action<IEnumerable<GenderResponse>>? successAction = null);
|
||||||
|
Task GetGender(long id, Action<GenderResponse>? successAction = null, Action? notFoundAction = null);
|
||||||
|
Task PostGender(GenderRequest data, Action<GenderResponse>? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null);
|
||||||
|
Task DeleteGender(long id, Action? successAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null);
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\..\..\..\WatchIt.Common\WatchIt.Common.Services\WatchIt.Common.Services.HttpClient\WatchIt.Common.Services.HttpClient.csproj" />
|
||||||
|
<ProjectReference Include="..\WatchIt.Website.Services.WebAPI.Common\WatchIt.Website.Services.WebAPI.Common.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
@@ -9,5 +9,10 @@ public interface IPersonsWebAPIService
|
|||||||
Task PostPerson(PersonRequest data, Action<PersonResponse>? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null);
|
Task PostPerson(PersonRequest data, Action<PersonResponse>? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null);
|
||||||
Task PutPerson(long id, PersonRequest data, Action? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null);
|
Task PutPerson(long id, PersonRequest data, Action? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null);
|
||||||
Task DeletePerson(long id, Action? successAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null);
|
Task DeletePerson(long id, Action? successAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null);
|
||||||
|
|
||||||
Task GetPersonsViewRank(int? first = null, int? days = null, Action<IEnumerable<PersonResponse>>? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null);
|
Task GetPersonsViewRank(int? first = null, int? days = null, Action<IEnumerable<PersonResponse>>? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null);
|
||||||
|
|
||||||
|
Task GetPersonPhoto(long id, Action<PersonPhotoResponse>? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? notFoundAction = null);
|
||||||
|
Task PutPersonPhoto(long id, PersonPhotoRequest data, Action<PersonPhotoResponse>? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null);
|
||||||
|
Task DeletePersonPhoto(long id, Action? successAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null);
|
||||||
}
|
}
|
||||||
@@ -138,6 +138,53 @@ public class PersonsWebAPIService : BaseWebAPIService, IPersonsWebAPIService
|
|||||||
.ExecuteAction();
|
.ExecuteAction();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Photo
|
||||||
|
|
||||||
|
public async Task GetPersonPhoto(long id, Action<PersonPhotoResponse>? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? notFoundAction = null)
|
||||||
|
{
|
||||||
|
string url = GetUrl(EndpointsConfiguration.Persons.GetPersonPhoto, id);
|
||||||
|
|
||||||
|
HttpRequest request = new HttpRequest(HttpMethodType.Get, url);
|
||||||
|
|
||||||
|
HttpResponse response = await _httpClientService.SendRequestAsync(request);
|
||||||
|
response.RegisterActionFor2XXSuccess(successAction)
|
||||||
|
.RegisterActionFor400BadRequest(badRequestAction)
|
||||||
|
.RegisterActionFor404NotFound(notFoundAction)
|
||||||
|
.ExecuteAction();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task PutPersonPhoto(long id, PersonPhotoRequest data, Action<PersonPhotoResponse>? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null)
|
||||||
|
{
|
||||||
|
string url = GetUrl(EndpointsConfiguration.Persons.PutPersonPhoto, id);
|
||||||
|
|
||||||
|
HttpRequest request = new HttpRequest(HttpMethodType.Put, url)
|
||||||
|
{
|
||||||
|
Body = data
|
||||||
|
};
|
||||||
|
|
||||||
|
HttpResponse response = await _httpClientService.SendRequestAsync(request);
|
||||||
|
response.RegisterActionFor2XXSuccess(successAction)
|
||||||
|
.RegisterActionFor400BadRequest(badRequestAction)
|
||||||
|
.RegisterActionFor401Unauthorized(unauthorizedAction)
|
||||||
|
.RegisterActionFor403Forbidden(forbiddenAction)
|
||||||
|
.ExecuteAction();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task DeletePersonPhoto(long id, Action? successAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null)
|
||||||
|
{
|
||||||
|
string url = GetUrl(EndpointsConfiguration.Persons.DeletePersonPhoto, id);
|
||||||
|
|
||||||
|
HttpRequest request = new HttpRequest(HttpMethodType.Delete, url);
|
||||||
|
|
||||||
|
HttpResponse response = await _httpClientService.SendRequestAsync(request);
|
||||||
|
response.RegisterActionFor2XXSuccess(successAction)
|
||||||
|
.RegisterActionFor401Unauthorized(unauthorizedAction)
|
||||||
|
.RegisterActionFor403Forbidden(forbiddenAction)
|
||||||
|
.ExecuteAction();
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@@ -0,0 +1,76 @@
|
|||||||
|
@using WatchIt.Common.Model.Genders
|
||||||
|
<div class="rounded-3 panel panel-regular p-3 @(Class)">
|
||||||
|
@if (_loaded)
|
||||||
|
{
|
||||||
|
<EditForm Model="_person">
|
||||||
|
<AntiforgeryToken/>
|
||||||
|
<div class="container-grid">
|
||||||
|
<div class="row form-group mb-1">
|
||||||
|
<label for="name" class="col-2 col-form-label">Name*</label>
|
||||||
|
<div class="col-10">
|
||||||
|
<InputText id="name" class="form-control" @bind-Value="_person!.Name"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row form-group mb-1">
|
||||||
|
<label for="fullName" class="col-2 col-form-label">Full name</label>
|
||||||
|
<div class="col-10">
|
||||||
|
<InputText id="fullName" class="form-control" @bind-Value="_person!.FullName"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row form-group my-1">
|
||||||
|
<label for="desc" class="col-2 col-form-label">Description</label>
|
||||||
|
<div class="col-10">
|
||||||
|
<InputTextArea id="desc" class="form-control" @bind-Value="_person!.Description"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row form-group mb-1">
|
||||||
|
<label for="birthDeathDates" class="col-2 col-form-label">Birth and death</label>
|
||||||
|
<div class="col-10">
|
||||||
|
<div id="birthDeathDates" class="input-group">
|
||||||
|
<InputDate TValue="DateOnly?" class="form-control" @bind-Value="_person!.BirthDate"/>
|
||||||
|
<span class="input-group-text">-</span>
|
||||||
|
<InputDate TValue="DateOnly?" class="form-control" @bind-Value="_person!.DeathDate"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row form-group my-1">
|
||||||
|
<label for="desc" class="col-2 col-form-label">Gender</label>
|
||||||
|
<div class="col-10">
|
||||||
|
<InputSelect TValue="short?" id="desc" class="form-control" @bind-Value="_person!.GenderId">
|
||||||
|
<option value="@(default(short?))">No choice</option>
|
||||||
|
@foreach (GenderResponse gender in _genders)
|
||||||
|
{
|
||||||
|
<option value="@(gender.Id)">@(gender.Name)</option>
|
||||||
|
}
|
||||||
|
</InputSelect>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col align-self-center">
|
||||||
|
@if (!string.IsNullOrWhiteSpace(_error))
|
||||||
|
{
|
||||||
|
<span class="text-danger">@(_error)</span>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
<div class="col-auto">
|
||||||
|
<button type="submit" class="btn btn-secondary" disabled="@(_saving)" @onclick="@(Save)">
|
||||||
|
@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>
|
||||||
|
</EditForm>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<LoadingComponent Color="white"/>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
@@ -0,0 +1,110 @@
|
|||||||
|
using Microsoft.AspNetCore.Components;
|
||||||
|
using WatchIt.Common.Model.Genders;
|
||||||
|
using WatchIt.Common.Model.Persons;
|
||||||
|
using WatchIt.Website.Services.WebAPI.Genders;
|
||||||
|
using WatchIt.Website.Services.WebAPI.Persons;
|
||||||
|
|
||||||
|
namespace WatchIt.Website.Components.PersonEditPage;
|
||||||
|
|
||||||
|
public partial class PersonEditFormComponent : ComponentBase
|
||||||
|
{
|
||||||
|
#region SERVICES
|
||||||
|
|
||||||
|
[Inject] private NavigationManager NavigationManager { get; set; } = default!;
|
||||||
|
[Inject] private IPersonsWebAPIService PersonsWebAPIService { get; set; } = default!;
|
||||||
|
[Inject] private IGendersWebAPIService GendersWebAPIService { get; set; } = default!;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#region PARAMETERS
|
||||||
|
|
||||||
|
[Parameter] public long? Id { get; set; }
|
||||||
|
[Parameter] public string Class { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#region FIELDS
|
||||||
|
|
||||||
|
private bool _loaded;
|
||||||
|
private bool _saving;
|
||||||
|
private string? _error;
|
||||||
|
|
||||||
|
private IEnumerable<GenderResponse> _genders = [];
|
||||||
|
|
||||||
|
private PersonRequest _person = new PersonRequest();
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#region PRIVATE METHODS
|
||||||
|
|
||||||
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||||
|
{
|
||||||
|
if (firstRender)
|
||||||
|
{
|
||||||
|
List<Task> endTasks = new List<Task>();
|
||||||
|
|
||||||
|
// STEP 0
|
||||||
|
endTasks.AddRange(
|
||||||
|
[
|
||||||
|
GendersWebAPIService.GetAllGenders(successAction: data => _genders = data)
|
||||||
|
]);
|
||||||
|
if (Id.HasValue)
|
||||||
|
{
|
||||||
|
endTasks.AddRange(
|
||||||
|
[
|
||||||
|
PersonsWebAPIService.GetPerson(Id.Value, data => _person = new PersonRequest(data))
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// END
|
||||||
|
await Task.WhenAll(endTasks);
|
||||||
|
|
||||||
|
_loaded = true;
|
||||||
|
StateHasChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task Save()
|
||||||
|
{
|
||||||
|
void PutSuccess()
|
||||||
|
{
|
||||||
|
_error = null;
|
||||||
|
_saving = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PostSuccess(PersonResponse data)
|
||||||
|
{
|
||||||
|
NavigationManager.NavigateTo($"person/{data.Id}/edit");
|
||||||
|
}
|
||||||
|
|
||||||
|
void BadRequest(IDictionary<string, string[]> errors)
|
||||||
|
{
|
||||||
|
_error = errors.SelectMany(x => x.Value).FirstOrDefault() ?? "Unknown error";
|
||||||
|
_saving = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AuthError()
|
||||||
|
{
|
||||||
|
_error = "Authentication error";
|
||||||
|
_saving = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
_saving = true;
|
||||||
|
if (Id.HasValue)
|
||||||
|
{
|
||||||
|
await PersonsWebAPIService.PutPerson(Id.Value, _person, PutSuccess, BadRequest, AuthError, AuthError);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
await PersonsWebAPIService.PostPerson(_person, PostSuccess, BadRequest, AuthError, AuthError);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
<div class="rounded-3 panel panel-regular p-3 @(Class)">
|
||||||
|
@if (_loaded)
|
||||||
|
{
|
||||||
|
<div class="vstack gap-3">
|
||||||
|
<img class="rounded-2 shadow object-fit-cover picture-aspect-ratio" src="@(_pictureSelected is not null ? _pictureSelected.ToString() : PicturePlaceholder)" alt="poster" width="@(ContentWidth)"/>
|
||||||
|
<InputFile class="form-control content-width" OnChange="Load" disabled="@(!Id.HasValue)" autocomplete="off"/>
|
||||||
|
@if (_pictureChanged || _pictureSaved is not null)
|
||||||
|
{
|
||||||
|
<div class="d-flex gap-1 content-width">
|
||||||
|
@if (_pictureChanged)
|
||||||
|
{
|
||||||
|
<div class="flex-fill">
|
||||||
|
<button type="button" class="btn btn-secondary btn-block btn-stretch-x" @onclick="Save" disabled=@(!Id.HasValue || _pictureSaving || _pictureDeleting) autocomplete="off">
|
||||||
|
@if (!_pictureSaving)
|
||||||
|
{
|
||||||
|
<span>Save</span>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
|
||||||
|
<span>Saving...</span>
|
||||||
|
}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="flex-fill">
|
||||||
|
<button type="button" class="btn btn-danger btn-block btn-stretch-x" @onclick="Cancel" disabled=@(!Id.HasValue || _pictureSaving || _pictureDeleting) autocomplete="off">Drop changes</button>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
else if (_pictureSaved is not null)
|
||||||
|
{
|
||||||
|
<div class="flex-fill">
|
||||||
|
<button type="button" class="btn btn-danger btn-block btn-stretch-x" @onclick="Delete" disabled=@(!Id.HasValue || _pictureSaving || _pictureDeleting) autocomplete="off">
|
||||||
|
@if (!_pictureSaving)
|
||||||
|
{
|
||||||
|
<span>Delete</span>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
|
||||||
|
<span>Deleting...</span>
|
||||||
|
}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<div class="d-flex align-items-center justify-content-center h-100 content-width">
|
||||||
|
<LoadingComponent/>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<style>
|
||||||
|
/* CLASSES */
|
||||||
|
|
||||||
|
.content-width {
|
||||||
|
width: @(ContentWidth);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,122 @@
|
|||||||
|
using Microsoft.AspNetCore.Components;
|
||||||
|
using Microsoft.AspNetCore.Components.Forms;
|
||||||
|
using WatchIt.Common.Model;
|
||||||
|
|
||||||
|
namespace WatchIt.Website.Components;
|
||||||
|
|
||||||
|
public partial class PictureEditorComponent : ComponentBase
|
||||||
|
{
|
||||||
|
#region PARAMETERS
|
||||||
|
|
||||||
|
[Parameter] public long? Id { get; set; }
|
||||||
|
[Parameter] public int ContentWidth { get; set; } = 300;
|
||||||
|
[Parameter] public string PicturePlaceholder { get; set; } = "assets/poster.png";
|
||||||
|
[Parameter] public string Class { get; set; } = string.Empty;
|
||||||
|
[Parameter] public required Func<long, Action<Picture>, Task> PictureGetTask { get; set; }
|
||||||
|
[Parameter] public required Func<long, Picture, Action<Picture>, Task> PicturePutTask { get; set; }
|
||||||
|
[Parameter] public required Func<long, Action, Task> PictureDeleteTask { get; set; }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#region FIELDS
|
||||||
|
|
||||||
|
private bool _loaded;
|
||||||
|
|
||||||
|
private Picture? _pictureSaved;
|
||||||
|
private Picture? _pictureSelected;
|
||||||
|
private bool _pictureChanged;
|
||||||
|
private bool _pictureSaving;
|
||||||
|
private bool _pictureDeleting;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#region PRIVATE METHODS
|
||||||
|
|
||||||
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||||
|
{
|
||||||
|
if (firstRender)
|
||||||
|
{
|
||||||
|
List<Task> endTask = new List<Task>();
|
||||||
|
|
||||||
|
// STEP 0
|
||||||
|
if (Id.HasValue)
|
||||||
|
{
|
||||||
|
endTask.AddRange(
|
||||||
|
[
|
||||||
|
PictureGetTask(Id.Value, data =>
|
||||||
|
{
|
||||||
|
_pictureSaved = data;
|
||||||
|
_pictureSelected = data;
|
||||||
|
})
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// END
|
||||||
|
await Task.WhenAll(endTask);
|
||||||
|
|
||||||
|
_loaded = true;
|
||||||
|
StateHasChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task Load(InputFileChangeEventArgs args)
|
||||||
|
{
|
||||||
|
if (args.File.ContentType.StartsWith("image"))
|
||||||
|
{
|
||||||
|
Stream stream = args.File.OpenReadStream(5242880);
|
||||||
|
byte[] array;
|
||||||
|
using (MemoryStream ms = new MemoryStream())
|
||||||
|
{
|
||||||
|
await stream.CopyToAsync(ms);
|
||||||
|
array = ms.ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
_pictureSelected = new Picture
|
||||||
|
{
|
||||||
|
Image = array,
|
||||||
|
MimeType = args.File.ContentType
|
||||||
|
};
|
||||||
|
_pictureChanged = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task Save()
|
||||||
|
{
|
||||||
|
void Success(Picture data)
|
||||||
|
{
|
||||||
|
_pictureSaved = data;
|
||||||
|
_pictureSelected = data;
|
||||||
|
_pictureChanged = false;
|
||||||
|
_pictureSaving = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
_pictureSaving = true;
|
||||||
|
await PicturePutTask(Id.Value, _pictureSelected, Success);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Cancel()
|
||||||
|
{
|
||||||
|
_pictureSelected = _pictureSaved;
|
||||||
|
_pictureChanged = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task Delete()
|
||||||
|
{
|
||||||
|
void Success()
|
||||||
|
{
|
||||||
|
_pictureSaved = null;
|
||||||
|
_pictureSelected = null;
|
||||||
|
_pictureChanged = false;
|
||||||
|
_pictureDeleting = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
_pictureDeleting = true;
|
||||||
|
await PictureDeleteTask(Id.Value, Success);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
@@ -14,14 +14,14 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<a class="col rounded-3 panel panel-regular m-1" href="/media/new/movies">
|
<a class="col rounded-3 panel panel-regular m-1" href="/media/new/movies">
|
||||||
<p class="text-center text-decorations-none">New movie</p>
|
<p class="text-center text-reset text-decorations-none">New movie</p>
|
||||||
|
</a>
|
||||||
|
<a class="col rounded-3 panel panel-regular m-1" href="/media/new/series">
|
||||||
|
<p class="text-center text-reset text-decorations-none">New TV series</p>
|
||||||
|
</a>
|
||||||
|
<a class="col rounded-3 panel panel-regular m-1" href="/person/new">
|
||||||
|
<p class="text-center text-reset text-decorations-none">New person</p>
|
||||||
</a>
|
</a>
|
||||||
<div class="col rounded-3 panel panel-regular m-1">
|
|
||||||
<p class="text-center">New TV series</p>
|
|
||||||
</div>
|
|
||||||
<div class="col rounded-3 panel panel-regular m-1">
|
|
||||||
<p class="text-center">New TV series</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -7,12 +7,17 @@
|
|||||||
|
|
||||||
|
|
||||||
<PageTitle>
|
<PageTitle>
|
||||||
|
@("WatchIt - ")
|
||||||
@switch (Type)
|
@switch (Type)
|
||||||
{
|
{
|
||||||
case "movies": @("Movies"); break;
|
case "movies":
|
||||||
case "series": @("Series"); break;
|
@("Movies");
|
||||||
|
break;
|
||||||
|
case "series":
|
||||||
|
@("Series");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
@(" database - WatchIt")
|
@(" database")
|
||||||
</PageTitle>
|
</PageTitle>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
73
WatchIt.Website/WatchIt.Website/Pages/PersonEditPage.razor
Normal file
73
WatchIt.Website/WatchIt.Website/Pages/PersonEditPage.razor
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
@using WatchIt.Common.Model.Persons
|
||||||
|
|
||||||
|
@page "/person/{id:long}/edit"
|
||||||
|
@page "/person/new"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<PageTitle>
|
||||||
|
WatchIt -
|
||||||
|
@if (_loaded)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(_error) && _user?.IsAdmin == true)
|
||||||
|
{
|
||||||
|
if (_person is not null)
|
||||||
|
{
|
||||||
|
@("Edit \"")@(_person.Name)@("\"")
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
@("Create new person")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
@("Error")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
@("Loading")
|
||||||
|
}
|
||||||
|
</PageTitle>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@if (_loaded)
|
||||||
|
{
|
||||||
|
if (_user?.IsAdmin == true)
|
||||||
|
{
|
||||||
|
<div class="container-grid">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col">
|
||||||
|
<div class="rounded-3 panel panel-regular p-2 px-3">
|
||||||
|
<h3 class="m-0 p-0">@(Id is not null ? "Edit" : "Create new") person @(_person is not null ? $" \"{_person.Name}\"" : string.Empty)</h3>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mt-3 gx-3">
|
||||||
|
<div class="col-auto">
|
||||||
|
<PictureEditorComponent Id="@(Id)"
|
||||||
|
PictureGetTask="@(async (id, action) => await PersonsWebAPIService.GetPersonPhoto(id, action))"
|
||||||
|
PicturePutTask="@(async (id, data, action) => await PersonsWebAPIService.PutPersonPhoto(id, new PersonPhotoRequest(data), action))"
|
||||||
|
PictureDeleteTask="@(async (id, action) => await PersonsWebAPIService.DeletePersonPhoto(id, action))"
|
||||||
|
Class="h-100"/>
|
||||||
|
</div>
|
||||||
|
<div class="col">
|
||||||
|
<PersonEditFormComponent Id="@(Id)"
|
||||||
|
Class="h-100"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<ErrorComponent ErrorMessage="You do not have permission to view this site"/>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<div class="m-5">
|
||||||
|
<LoadingComponent/>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
@@ -0,0 +1,77 @@
|
|||||||
|
using Microsoft.AspNetCore.Components;
|
||||||
|
using WatchIt.Common.Model.Persons;
|
||||||
|
using WatchIt.Website.Layout;
|
||||||
|
using WatchIt.Website.Services.Utility.Authentication;
|
||||||
|
using WatchIt.Website.Services.WebAPI.Persons;
|
||||||
|
|
||||||
|
namespace WatchIt.Website.Pages;
|
||||||
|
|
||||||
|
public partial class PersonEditPage : ComponentBase
|
||||||
|
{
|
||||||
|
#region SERVICES
|
||||||
|
|
||||||
|
[Inject] private IAuthenticationService AuthenticationService { get; set; } = default!;
|
||||||
|
[Inject] private IPersonsWebAPIService PersonsWebAPIService { get; set; } = default!;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#region PARAMETERS
|
||||||
|
|
||||||
|
[Parameter] public long? Id { get; set; }
|
||||||
|
|
||||||
|
[CascadingParameter] public MainLayout Layout { get; set; }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#region FIELDS
|
||||||
|
|
||||||
|
private bool _loaded;
|
||||||
|
private string? _error;
|
||||||
|
|
||||||
|
private User? _user;
|
||||||
|
|
||||||
|
private PersonResponse? _person;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#region PRIVATE METHODS
|
||||||
|
|
||||||
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||||
|
{
|
||||||
|
if (firstRender)
|
||||||
|
{
|
||||||
|
List<Task> step1Tasks = new List<Task>();
|
||||||
|
List<Task> endTasks = new List<Task>();
|
||||||
|
|
||||||
|
// STEP 0
|
||||||
|
step1Tasks.AddRange(
|
||||||
|
[
|
||||||
|
Task.Run(async () => _user = await AuthenticationService.GetUserAsync())
|
||||||
|
]);
|
||||||
|
|
||||||
|
// STEP 1
|
||||||
|
await Task.WhenAll(step1Tasks);
|
||||||
|
if (_user?.IsAdmin == true && Id.HasValue)
|
||||||
|
{
|
||||||
|
endTasks.AddRange(
|
||||||
|
[
|
||||||
|
PersonsWebAPIService.GetPerson(Id.Value, data => _person = data)
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// END
|
||||||
|
await Task.WhenAll(endTasks);
|
||||||
|
|
||||||
|
_loaded = true;
|
||||||
|
StateHasChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
@@ -9,8 +9,10 @@ using WatchIt.Website.Services.Utility.Authentication;
|
|||||||
using WatchIt.Website.Services.Utility.Configuration;
|
using WatchIt.Website.Services.Utility.Configuration;
|
||||||
using WatchIt.Website.Services.Utility.Tokens;
|
using WatchIt.Website.Services.Utility.Tokens;
|
||||||
using WatchIt.Website.Services.WebAPI.Accounts;
|
using WatchIt.Website.Services.WebAPI.Accounts;
|
||||||
|
using WatchIt.Website.Services.WebAPI.Genders;
|
||||||
using WatchIt.Website.Services.WebAPI.Media;
|
using WatchIt.Website.Services.WebAPI.Media;
|
||||||
using WatchIt.Website.Services.WebAPI.Movies;
|
using WatchIt.Website.Services.WebAPI.Movies;
|
||||||
|
using WatchIt.Website.Services.WebAPI.Persons;
|
||||||
using WatchIt.Website.Services.WebAPI.Photos;
|
using WatchIt.Website.Services.WebAPI.Photos;
|
||||||
using WatchIt.Website.Services.WebAPI.Series;
|
using WatchIt.Website.Services.WebAPI.Series;
|
||||||
|
|
||||||
@@ -71,10 +73,12 @@ public static class Program
|
|||||||
|
|
||||||
// WebAPI
|
// WebAPI
|
||||||
builder.Services.AddScoped<IAccountsWebAPIService, AccountsWebAPIService>();
|
builder.Services.AddScoped<IAccountsWebAPIService, AccountsWebAPIService>();
|
||||||
|
builder.Services.AddSingleton<IGendersWebAPIService, GendersWebAPIService>();
|
||||||
builder.Services.AddSingleton<IMediaWebAPIService, MediaWebAPIService>();
|
builder.Services.AddSingleton<IMediaWebAPIService, MediaWebAPIService>();
|
||||||
builder.Services.AddSingleton<IMoviesWebAPIService, MoviesWebAPIService>();
|
builder.Services.AddSingleton<IMoviesWebAPIService, MoviesWebAPIService>();
|
||||||
builder.Services.AddSingleton<ISeriesWebAPIService, SeriesWebAPIService>();
|
builder.Services.AddSingleton<ISeriesWebAPIService, SeriesWebAPIService>();
|
||||||
builder.Services.AddSingleton<IPhotosWebAPIService, PhotosWebAPIService>();
|
builder.Services.AddSingleton<IPhotosWebAPIService, PhotosWebAPIService>();
|
||||||
|
builder.Services.AddSingleton<IPersonsWebAPIService, PersonsWebAPIService>();
|
||||||
|
|
||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,8 +20,10 @@
|
|||||||
<ProjectReference Include="..\WatchIt.Website.Services\WatchIt.Website.Services.Utility\WatchIt.Website.Services.Utility.Configuration\WatchIt.Website.Services.Utility.Configuration.csproj" />
|
<ProjectReference Include="..\WatchIt.Website.Services\WatchIt.Website.Services.Utility\WatchIt.Website.Services.Utility.Configuration\WatchIt.Website.Services.Utility.Configuration.csproj" />
|
||||||
<ProjectReference Include="..\WatchIt.Website.Services\WatchIt.Website.Services.Utility\WatchIt.Website.Services.Utility.Tokens\WatchIt.Website.Services.Utility.Tokens.csproj" />
|
<ProjectReference Include="..\WatchIt.Website.Services\WatchIt.Website.Services.Utility\WatchIt.Website.Services.Utility.Tokens\WatchIt.Website.Services.Utility.Tokens.csproj" />
|
||||||
<ProjectReference Include="..\WatchIt.Website.Services\WatchIt.Website.Services.WebAPI\WatchIt.Website.Services.WebAPI.Accounts\WatchIt.Website.Services.WebAPI.Accounts.csproj" />
|
<ProjectReference Include="..\WatchIt.Website.Services\WatchIt.Website.Services.WebAPI\WatchIt.Website.Services.WebAPI.Accounts\WatchIt.Website.Services.WebAPI.Accounts.csproj" />
|
||||||
|
<ProjectReference Include="..\WatchIt.Website.Services\WatchIt.Website.Services.WebAPI\WatchIt.Website.Services.WebAPI.Genders\WatchIt.Website.Services.WebAPI.Genders.csproj" />
|
||||||
<ProjectReference Include="..\WatchIt.Website.Services\WatchIt.Website.Services.WebAPI\WatchIt.Website.Services.WebAPI.Media\WatchIt.Website.Services.WebAPI.Media.csproj" />
|
<ProjectReference Include="..\WatchIt.Website.Services\WatchIt.Website.Services.WebAPI\WatchIt.Website.Services.WebAPI.Media\WatchIt.Website.Services.WebAPI.Media.csproj" />
|
||||||
<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.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.Photos\WatchIt.Website.Services.WebAPI.Photos.csproj" />
|
||||||
<ProjectReference Include="..\WatchIt.Website.Services\WatchIt.Website.Services.WebAPI\WatchIt.Website.Services.WebAPI.Series\WatchIt.Website.Services.WebAPI.Series.csproj" />
|
<ProjectReference Include="..\WatchIt.Website.Services\WatchIt.Website.Services.WebAPI\WatchIt.Website.Services.WebAPI.Series\WatchIt.Website.Services.WebAPI.Series.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
@using WatchIt.Website
|
@using WatchIt.Website
|
||||||
@using WatchIt.Website.Layout
|
@using WatchIt.Website.Layout
|
||||||
@using WatchIt.Website.Components
|
@using WatchIt.Website.Components
|
||||||
|
@using WatchIt.Website.Components.PersonEditPage
|
||||||
@using WatchIt.Common.Model.Accounts
|
@using WatchIt.Common.Model.Accounts
|
||||||
@using WatchIt.Common.Model.Media
|
@using WatchIt.Common.Model.Media
|
||||||
@using WatchIt.Website.Services.Utility.Tokens
|
@using WatchIt.Website.Services.Utility.Tokens
|
||||||
|
|||||||
@@ -20,6 +20,13 @@
|
|||||||
"Logout": "/logout",
|
"Logout": "/logout",
|
||||||
"GetProfilePicture": "/{0}/profile-picture"
|
"GetProfilePicture": "/{0}/profile-picture"
|
||||||
},
|
},
|
||||||
|
"Genders": {
|
||||||
|
"Base": "/genders",
|
||||||
|
"GetAllGenders": "",
|
||||||
|
"GetGender": "/{0}",
|
||||||
|
"PostGender": "",
|
||||||
|
"DeleteGender": "/{0}"
|
||||||
|
},
|
||||||
"Genres": {
|
"Genres": {
|
||||||
"Base": "/genres",
|
"Base": "/genres",
|
||||||
"GetAll": "",
|
"GetAll": "",
|
||||||
@@ -78,7 +85,10 @@
|
|||||||
"PostPerson": "",
|
"PostPerson": "",
|
||||||
"PutPerson": "/{0}",
|
"PutPerson": "/{0}",
|
||||||
"DeletePerson": "/{0}",
|
"DeletePerson": "/{0}",
|
||||||
"GetPersonsViewRank": "/view"
|
"GetPersonsViewRank": "/view",
|
||||||
|
"GetPersonPhoto": "/{0}/poster",
|
||||||
|
"PutPersonPhoto": "/{0}/poster",
|
||||||
|
"DeletePersonPhoto": "/{0}/poster"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
14
WatchIt.sln
14
WatchIt.sln
@@ -92,6 +92,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WatchIt.WebAPI.Services.Con
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WatchIt.Website.Services.WebAPI.Persons", "WatchIt.Website\WatchIt.Website.Services\WatchIt.Website.Services.WebAPI\WatchIt.Website.Services.WebAPI.Persons\WatchIt.Website.Services.WebAPI.Persons.csproj", "{83D42D72-FF67-4577-8280-2ABD5B20F985}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WatchIt.Website.Services.WebAPI.Persons", "WatchIt.Website\WatchIt.Website.Services\WatchIt.Website.Services.WebAPI\WatchIt.Website.Services.WebAPI.Persons\WatchIt.Website.Services.WebAPI.Persons.csproj", "{83D42D72-FF67-4577-8280-2ABD5B20F985}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WatchIt.WebAPI.Services.Controllers.Genders", "WatchIt.WebAPI\WatchIt.WebAPI.Services\WatchIt.WebAPI.Services.Controllers\WatchIt.WebAPI.Services.Controllers.Genders\WatchIt.WebAPI.Services.Controllers.Genders.csproj", "{13BE36AB-2120-4F1B-815A-6F5E3F589EE8}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WatchIt.Website.Services.WebAPI.Genders", "WatchIt.Website\WatchIt.Website.Services\WatchIt.Website.Services.WebAPI\WatchIt.Website.Services.WebAPI.Genders\WatchIt.Website.Services.WebAPI.Genders.csproj", "{B74144DE-EF62-430A-AB80-5D185DD03C05}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@@ -140,6 +144,8 @@ Global
|
|||||||
{960A833F-C195-4D1D-AD4F-D00B57067181} = {46E3711F-18BD-4004-AF53-EA4D8643D92F}
|
{960A833F-C195-4D1D-AD4F-D00B57067181} = {46E3711F-18BD-4004-AF53-EA4D8643D92F}
|
||||||
{335686F5-65B8-4D66-AAA8-C5032906451D} = {CEC468DB-CC49-47D3-9E3E-1CC9530C3CE7}
|
{335686F5-65B8-4D66-AAA8-C5032906451D} = {CEC468DB-CC49-47D3-9E3E-1CC9530C3CE7}
|
||||||
{83D42D72-FF67-4577-8280-2ABD5B20F985} = {46E3711F-18BD-4004-AF53-EA4D8643D92F}
|
{83D42D72-FF67-4577-8280-2ABD5B20F985} = {46E3711F-18BD-4004-AF53-EA4D8643D92F}
|
||||||
|
{13BE36AB-2120-4F1B-815A-6F5E3F589EE8} = {CEC468DB-CC49-47D3-9E3E-1CC9530C3CE7}
|
||||||
|
{B74144DE-EF62-430A-AB80-5D185DD03C05} = {46E3711F-18BD-4004-AF53-EA4D8643D92F}
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
{23383776-1F27-4B5D-8C7C-57BFF75FA473}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{23383776-1F27-4B5D-8C7C-57BFF75FA473}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
@@ -278,5 +284,13 @@ Global
|
|||||||
{83D42D72-FF67-4577-8280-2ABD5B20F985}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{83D42D72-FF67-4577-8280-2ABD5B20F985}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{83D42D72-FF67-4577-8280-2ABD5B20F985}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{83D42D72-FF67-4577-8280-2ABD5B20F985}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{83D42D72-FF67-4577-8280-2ABD5B20F985}.Release|Any CPU.Build.0 = Release|Any CPU
|
{83D42D72-FF67-4577-8280-2ABD5B20F985}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{13BE36AB-2120-4F1B-815A-6F5E3F589EE8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{13BE36AB-2120-4F1B-815A-6F5E3F589EE8}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{13BE36AB-2120-4F1B-815A-6F5E3F589EE8}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{13BE36AB-2120-4F1B-815A-6F5E3F589EE8}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{B74144DE-EF62-430A-AB80-5D185DD03C05}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{B74144DE-EF62-430A-AB80-5D185DD03C05}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{B74144DE-EF62-430A-AB80-5D185DD03C05}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{B74144DE-EF62-430A-AB80-5D185DD03C05}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
|||||||
Reference in New Issue
Block a user