diff --git a/WatchIt.WebAPI/WatchIt.WebAPI.Controllers/GenresController.cs b/WatchIt.WebAPI/WatchIt.WebAPI.Controllers/GenresController.cs index 5d48fbb..c3f76ff 100644 --- a/WatchIt.WebAPI/WatchIt.WebAPI.Controllers/GenresController.cs +++ b/WatchIt.WebAPI/WatchIt.WebAPI.Controllers/GenresController.cs @@ -2,6 +2,7 @@ using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using WatchIt.Common.Model.Genres; +using WatchIt.Common.Model.Media; using WatchIt.WebAPI.Services.Controllers.Genres; namespace WatchIt.WebAPI.Controllers; @@ -10,16 +11,20 @@ namespace WatchIt.WebAPI.Controllers; [Route("genres")] public class GenresController(IGenresControllerService genresControllerService) : ControllerBase { + #region METHODS + + #region Main + [HttpGet] [AllowAnonymous] [ProducesResponseType(typeof(IEnumerable), StatusCodes.Status200OK)] - public async Task GetAll(GenreQueryParameters query) => await genresControllerService.GetAll(query); + public async Task GetGenres(GenreQueryParameters query) => await genresControllerService.GetGenres(query); [HttpGet("{id}")] [AllowAnonymous] [ProducesResponseType(typeof(GenreResponse), StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status404NotFound)] - public async Task Get([FromRoute]short id) => await genresControllerService.Get(id); + public async Task GetGenre([FromRoute]short id) => await genresControllerService.GetGenre(id); [HttpPost] [Authorize] @@ -27,7 +32,7 @@ public class GenresController(IGenresControllerService genresControllerService) [ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)] [ProducesResponseType(typeof(void), StatusCodes.Status401Unauthorized)] [ProducesResponseType(typeof(void), StatusCodes.Status403Forbidden)] - public async Task Post([FromBody]GenreRequest body) => await genresControllerService.Post(body); + public async Task PostGenre([FromBody]GenreRequest body) => await genresControllerService.PostGenre(body); [HttpPut("{id}")] [Authorize] @@ -35,7 +40,7 @@ public class GenresController(IGenresControllerService genresControllerService) [ProducesResponseType(typeof(void), StatusCodes.Status401Unauthorized)] [ProducesResponseType(typeof(void), StatusCodes.Status403Forbidden)] [ProducesResponseType(StatusCodes.Status404NotFound)] - public async Task Put([FromRoute]short id, [FromBody]GenreRequest body) => await genresControllerService.Put(id, body); + public async Task PutGenre([FromRoute]short id, [FromBody]GenreRequest body) => await genresControllerService.PutGenre(id, body); [HttpDelete("{id}")] [Authorize] @@ -44,5 +49,19 @@ public class GenresController(IGenresControllerService genresControllerService) [ProducesResponseType(typeof(void), StatusCodes.Status401Unauthorized)] [ProducesResponseType(typeof(void), StatusCodes.Status403Forbidden)] [ProducesResponseType(StatusCodes.Status404NotFound)] - public async Task Delete([FromRoute]short id) => await genresControllerService.Delete(id); + public async Task DeleteGenre([FromRoute]short id) => await genresControllerService.DeleteGenre(id); + + #endregion + + #region Media + + [HttpGet("{id}/media")] + [AllowAnonymous] + [ProducesResponseType(typeof(IEnumerable), StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status404NotFound)] + public async Task GetGenreMedia([FromRoute]short id, MediaQueryParameters query) => await genresControllerService.GetGenreMedia(id, query); + + #endregion + + #endregion } \ No newline at end of file diff --git a/WatchIt.WebAPI/WatchIt.WebAPI.Services/WatchIt.WebAPI.Services.Controllers/WatchIt.WebAPI.Services.Controllers.Genres/GenresControllerService.cs b/WatchIt.WebAPI/WatchIt.WebAPI.Services/WatchIt.WebAPI.Services.Controllers/WatchIt.WebAPI.Services.Controllers.Genres/GenresControllerService.cs index 5357aa8..0d350dd 100644 --- a/WatchIt.WebAPI/WatchIt.WebAPI.Services/WatchIt.WebAPI.Services.Controllers/WatchIt.WebAPI.Services.Controllers.Genres/GenresControllerService.cs +++ b/WatchIt.WebAPI/WatchIt.WebAPI.Services/WatchIt.WebAPI.Services.Controllers/WatchIt.WebAPI.Services.Controllers.Genres/GenresControllerService.cs @@ -1,5 +1,6 @@ using Microsoft.EntityFrameworkCore; using WatchIt.Common.Model.Genres; +using WatchIt.Common.Model.Media; using WatchIt.Database; using WatchIt.Database.Model.Media; using WatchIt.WebAPI.Services.Controllers.Common; @@ -12,14 +13,16 @@ public class GenresControllerService(DatabaseContext database, IUserService user { #region PUBLIC METHODS - public async Task GetAll(GenreQueryParameters query) + #region Main + + public async Task GetGenres(GenreQueryParameters query) { IEnumerable data = await database.Genres.Select(x => new GenreResponse(x)).ToListAsync(); data = query.PrepareData(data); return RequestResult.Ok(data); } - public async Task Get(short id) + public async Task GetGenre(short id) { Genre? item = await database.Genres.FirstOrDefaultAsync(x => x.Id == id); if (item is null) @@ -31,7 +34,7 @@ public class GenresControllerService(DatabaseContext database, IUserService user return RequestResult.Ok(data); } - public async Task Post(GenreRequest data) + public async Task PostGenre(GenreRequest data) { UserValidator validator = userService.GetValidator().MustBeAdmin(); if (!validator.IsValid) @@ -46,7 +49,7 @@ public class GenresControllerService(DatabaseContext database, IUserService user return RequestResult.Created($"genres/{item.Id}", new GenreResponse(item)); } - public async Task Put(short id, GenreRequest data) + public async Task PutGenre(short id, GenreRequest data) { UserValidator validator = userService.GetValidator().MustBeAdmin(); if (!validator.IsValid) @@ -66,7 +69,7 @@ public class GenresControllerService(DatabaseContext database, IUserService user return RequestResult.Ok(); } - public async Task Delete(short id) + public async Task DeleteGenre(short id) { UserValidator validator = userService.GetValidator().MustBeAdmin(); if (!validator.IsValid) @@ -88,6 +91,26 @@ public class GenresControllerService(DatabaseContext database, IUserService user return RequestResult.Ok(); } + + #endregion + + #region Media + + public async Task GetGenreMedia(short id, MediaQueryParameters query) + { + if (!database.Genres.Any(x => x.Id == id)) + { + return RequestResult.NotFound(); + } + + IEnumerable rawData = await database.Media.Where(x => x.MediaGenres.Any(y => y.GenreId == id)) + .ToListAsync(); + IEnumerable 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); + } + + #endregion #endregion } \ No newline at end of file diff --git a/WatchIt.WebAPI/WatchIt.WebAPI.Services/WatchIt.WebAPI.Services.Controllers/WatchIt.WebAPI.Services.Controllers.Genres/IGenresControllerService.cs b/WatchIt.WebAPI/WatchIt.WebAPI.Services/WatchIt.WebAPI.Services.Controllers/WatchIt.WebAPI.Services.Controllers.Genres/IGenresControllerService.cs index 4fc50a9..e1a358c 100644 --- a/WatchIt.WebAPI/WatchIt.WebAPI.Services/WatchIt.WebAPI.Services.Controllers/WatchIt.WebAPI.Services.Controllers.Genres/IGenresControllerService.cs +++ b/WatchIt.WebAPI/WatchIt.WebAPI.Services/WatchIt.WebAPI.Services.Controllers/WatchIt.WebAPI.Services.Controllers.Genres/IGenresControllerService.cs @@ -1,13 +1,15 @@ using WatchIt.Common.Model.Genres; +using WatchIt.Common.Model.Media; using WatchIt.WebAPI.Services.Controllers.Common; namespace WatchIt.WebAPI.Services.Controllers.Genres; public interface IGenresControllerService { - Task GetAll(GenreQueryParameters query); - Task Get(short id); - Task Post(GenreRequest data); - Task Put(short id, GenreRequest data); - Task Delete(short id); + Task GetGenres(GenreQueryParameters query); + Task GetGenre(short id); + Task PostGenre(GenreRequest data); + Task PutGenre(short id, GenreRequest data); + Task DeleteGenre(short id); + Task GetGenreMedia(short id, MediaQueryParameters query); } \ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.Client/Genres/GenresClientService.cs b/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.Client/Genres/GenresClientService.cs new file mode 100644 index 0000000..48b96b3 --- /dev/null +++ b/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.Client/Genres/GenresClientService.cs @@ -0,0 +1,116 @@ +using WatchIt.Common.Model.Genders; +using WatchIt.Common.Model.Genres; +using WatchIt.Common.Model.Media; +using WatchIt.Common.Services.HttpClient; +using WatchIt.Website.Services.Configuration; + +namespace WatchIt.Website.Services.Client.Genres; + +public class GenresClientService : BaseClientService, IGenresClientService +{ + #region SERVICES + + private IHttpClientService _httpClientService; + private IConfigurationService _configurationService; + + #endregion + + + + #region CONSTRUCTORS + + public GenresClientService(IHttpClientService httpClientService, IConfigurationService configurationService) : base(configurationService) + { + _httpClientService = httpClientService; + _configurationService = configurationService; + } + + #endregion + + + + #region PUBLIC METHODS + + #region Main + + public async Task GetGenres(GenreQueryParameters? query = null, Action>? successAction = null) + { + string url = GetUrl(EndpointsConfiguration.Genres.GetGenres); + + HttpRequest request = new HttpRequest(HttpMethodType.Get, url); + request.Query = query; + + HttpResponse response = await _httpClientService.SendRequestAsync(request); + response.RegisterActionFor2XXSuccess(successAction) + .ExecuteAction(); + } + + public async Task GetGenre(long id, Action? successAction = null, Action? notFoundAction = null) + { + string url = GetUrl(EndpointsConfiguration.Genres.GetGenre, id); + + HttpRequest request = new HttpRequest(HttpMethodType.Get, url); + + HttpResponse response = await _httpClientService.SendRequestAsync(request); + response.RegisterActionFor2XXSuccess(successAction) + .RegisterActionFor404NotFound(notFoundAction) + .ExecuteAction(); + } + + public async Task PostGenre(GenreRequest data, Action? successAction = null, Action>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null) + { + string url = GetUrl(EndpointsConfiguration.Genres.PostGenre); + + 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 DeleteGenre(long id, Action? successAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null) + { + string url = GetUrl(EndpointsConfiguration.Genres.DeleteGenre, id); + + HttpRequest request = new HttpRequest(HttpMethodType.Delete, url); + + HttpResponse response = await _httpClientService.SendRequestAsync(request); + response.RegisterActionFor2XXSuccess(successAction) + .RegisterActionFor401Unauthorized(unauthorizedAction) + .RegisterActionFor403Forbidden(forbiddenAction) + .ExecuteAction(); + } + + #endregion + + #region Media + + public async Task GetGenreMedia(short id, MediaQueryParameters? query = null, Action>? successAction = null, Action notFoundAction = null) + { + string url = GetUrl(EndpointsConfiguration.Genres.GetGenreMedia, id); + + HttpRequest request = new HttpRequest(HttpMethodType.Get, url); + request.Query = query; + + HttpResponse response = await _httpClientService.SendRequestAsync(request); + response.RegisterActionFor2XXSuccess(successAction) + .RegisterActionFor404NotFound(notFoundAction) + .ExecuteAction(); + } + + #endregion + + #endregion + + + + #region PRIVATE METHODS + + protected override string GetServiceBase() => EndpointsConfiguration.Genres.Base; + + #endregion +} \ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.Client/Genres/IGenresClientService.cs b/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.Client/Genres/IGenresClientService.cs new file mode 100644 index 0000000..9115822 --- /dev/null +++ b/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.Client/Genres/IGenresClientService.cs @@ -0,0 +1,13 @@ +using WatchIt.Common.Model.Genres; +using WatchIt.Common.Model.Media; + +namespace WatchIt.Website.Services.Client.Genres; + +public interface IGenresClientService +{ + Task GetGenres(GenreQueryParameters? query = null, Action>? successAction = null); + Task GetGenre(long id, Action? successAction = null, Action? notFoundAction = null); + Task PostGenre(GenreRequest data, Action? successAction = null, Action>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null); + Task DeleteGenre(long id, Action? successAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null); + Task GetGenreMedia(short id, MediaQueryParameters? query = null, Action>? successAction = null, Action notFoundAction = null); +} \ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.Configuration/Model/Genres.cs b/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.Configuration/Model/Genres.cs index 59d41f4..1a30507 100644 --- a/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.Configuration/Model/Genres.cs +++ b/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.Configuration/Model/Genres.cs @@ -3,9 +3,10 @@ public class Genres { public string Base { get; set; } - public string GetAll { get; set; } - public string Get { get; set; } - public string Post { get; set; } - public string Put { get; set; } - public string Delete { get; set; } + public string GetGenres { get; set; } + public string GetGenre { get; set; } + public string PostGenre { get; set; } + public string PutGenre { get; set; } + public string DeleteGenre { get; set; } + public string GetGenreMedia { get; set; } } \ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Components/Common/ListComponent/ListComponent.razor.cs b/WatchIt.Website/WatchIt.Website/Components/Common/ListComponent/ListComponent.razor.cs index 5591ee6..b517f8e 100644 --- a/WatchIt.Website/WatchIt.Website/Components/Common/ListComponent/ListComponent.razor.cs +++ b/WatchIt.Website/WatchIt.Website/Components/Common/ListComponent/ListComponent.razor.cs @@ -36,6 +36,7 @@ public partial class ListComponent : ComponentBase where TItem : [Parameter] public Func? PutRatingMethod { get; set; } [Parameter] public Func? DeleteRatingMethod { get; set; } [Parameter] public required string PosterPlaceholder { get; set; } + [Parameter] public TQuery Query { get; set; } = Activator.CreateInstance()!; #endregion @@ -51,14 +52,6 @@ public partial class ListComponent : ComponentBase where TItem : private bool _itemsLoading; #endregion - - - - #region PROPERTIES - - public TQuery Query { get; set; } = Activator.CreateInstance()!; - - #endregion diff --git a/WatchIt.Website/WatchIt.Website/Components/Common/ListComponent/MediaFilterFormComponent.razor b/WatchIt.Website/WatchIt.Website/Components/Common/ListComponent/MediaFilterFormComponent.razor new file mode 100644 index 0000000..3c18d37 --- /dev/null +++ b/WatchIt.Website/WatchIt.Website/Components/Common/ListComponent/MediaFilterFormComponent.razor @@ -0,0 +1,68 @@ +@inherits WatchIt.Website.Components.Common.ListComponent.FilterFormComponent + + + + +
+
+
+ Type + + + + + +
+
+
+
+ Title + +
+
+
+
+ Original title + +
+
+
+
+ Description + +
+
+
+
+ Release date + + - + +
+
+
+
+ Length + + - + +
+
+
+
+ Rating (count) + + - + +
+
+
+
+ Rating (average) + + - + +
+
+
+
\ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Components/Pages/MediaEditPage/Panels/MediaEditPageHeaderPanelComponent.razor b/WatchIt.Website/WatchIt.Website/Components/Pages/MediaEditPage/Panels/MediaEditPageHeaderPanelComponent.razor new file mode 100644 index 0000000..f6c6ff6 --- /dev/null +++ b/WatchIt.Website/WatchIt.Website/Components/Pages/MediaEditPage/Panels/MediaEditPageHeaderPanelComponent.razor @@ -0,0 +1,18 @@ +
+
+ +
+

+ @if (MediaData is null) + { + New @(MediaType) + } + else + { + @(MediaData.Title)@(MediaData.ReleaseDate.HasValue ? $" ({MediaData.ReleaseDate.Value.Year})" : string.Empty) + } +

+ Media settings +
+
+
\ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Components/Pages/MediaEditPage/Panels/MediaEditPageHeaderPanelComponent.razor.cs b/WatchIt.Website/WatchIt.Website/Components/Pages/MediaEditPage/Panels/MediaEditPageHeaderPanelComponent.razor.cs new file mode 100644 index 0000000..52b3066 --- /dev/null +++ b/WatchIt.Website/WatchIt.Website/Components/Pages/MediaEditPage/Panels/MediaEditPageHeaderPanelComponent.razor.cs @@ -0,0 +1,52 @@ +using Microsoft.AspNetCore.Components; +using WatchIt.Common.Model.Media; +using WatchIt.Website.Services.Client.Media; + +namespace WatchIt.Website.Components.Pages.MediaEditPage.Panels; + +public partial class MediaEditPageHeaderPanelComponent : ComponentBase +{ + #region SERVICES + + [Inject] public IMediaClientService MediaClientService { get; set; } = default!; + [Inject] public NavigationManager NavigationManager { get; set; } = default!; + + #endregion + + + + #region PARAMETERS + + [Parameter] public required MediaResponse? MediaData { get; set; } + [Parameter] public required string MediaType { get; set; } + + #endregion + + + + #region FIELDS + + private MediaPosterResponse? _poster; + private List> _attr = new List>(); + + #endregion + + + + #region PRIVATE METHODS + + protected override async Task OnAfterRenderAsync(bool firstRender) + { + if (firstRender) + { + if (MediaData is not null) + { + await MediaClientService.GetMediaPoster(MediaData.Id, data => _poster = data); + _attr.Add(new KeyValuePair("@onclick", () => NavigationManager.NavigateTo($"/media/{MediaData.Id}"))); + StateHasChanged(); + } + } + } + + #endregion +} \ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Components/Pages/MediaEditPage/Panels/MediaEditPageHeaderPanelComponent.razor.css b/WatchIt.Website/WatchIt.Website/Components/Pages/MediaEditPage/Panels/MediaEditPageHeaderPanelComponent.razor.css new file mode 100644 index 0000000..bec8a67 --- /dev/null +++ b/WatchIt.Website/WatchIt.Website/Components/Pages/MediaEditPage/Panels/MediaEditPageHeaderPanelComponent.razor.css @@ -0,0 +1,9 @@ +/* IDS */ + +#primaryText { + margin-top: -8px !important; +} + +#secondaryText { + color: lightgray !important; +} \ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Components/Pages/MediaEditPage/Panels/MediaGenresEditPanelComponent.razor b/WatchIt.Website/WatchIt.Website/Components/Pages/MediaEditPage/Panels/MediaGenresEditPanelComponent.razor new file mode 100644 index 0000000..7a291fe --- /dev/null +++ b/WatchIt.Website/WatchIt.Website/Components/Pages/MediaEditPage/Panels/MediaGenresEditPanelComponent.razor @@ -0,0 +1,47 @@ +@using Blazorise.Extensions +@using WatchIt.Common.Model.Genres + + +
+
+

Genres

+
+ + + @foreach (GenreResponse genre in _availableGenres) + { + + } + + +
+ @if (_chosenGenres.IsNullOrEmpty()) + { + No items + } + else + { + + + @foreach (KeyValuePair genre in _chosenGenres) + { + + + + + } + +
+ @(genre.Key.Name) + + +
+ } +
+
\ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Components/Pages/MediaEditPage/Panels/MediaGenresEditPanelComponent.razor.cs b/WatchIt.Website/WatchIt.Website/Components/Pages/MediaEditPage/Panels/MediaGenresEditPanelComponent.razor.cs new file mode 100644 index 0000000..36b428e --- /dev/null +++ b/WatchIt.Website/WatchIt.Website/Components/Pages/MediaEditPage/Panels/MediaGenresEditPanelComponent.razor.cs @@ -0,0 +1,83 @@ +using Microsoft.AspNetCore.Components; +using WatchIt.Common.Model.Genres; +using WatchIt.Common.Model.Media; +using WatchIt.Website.Services.Client.Genres; +using WatchIt.Website.Services.Client.Media; + +namespace WatchIt.Website.Components.Pages.MediaEditPage.Panels; + +public partial class MediaGenresEditPanelComponent : ComponentBase +{ + #region SERVICES + + [Inject] private IGenresClientService GenresClientService { get; set; } = default!; + [Inject] private IMediaClientService MediaClientService { get; set; } = default!; + + #endregion + + + + #region PARAMETERS + + [Parameter] public required MediaResponse Data { get; set; } + + #endregion + + + + #region FIELDS + + private Dictionary _chosenGenres = new Dictionary(); + private List _availableGenres = new List(); + + private short? _selectedGenre; + private bool _addLoading; + + #endregion + + + + #region PRIVATE METHODS + + protected override async Task OnAfterRenderAsync(bool firstRender) + { + if (firstRender) + { + foreach (GenreResponse genre in Data.Genres) + { + _chosenGenres[genre] = false; + } + await GenresClientService.GetGenres(successAction: data => + { + IEnumerable tempSelected = _chosenGenres.Keys.Select(x => x.Id); + _availableGenres.AddRange(data.Where(x => !tempSelected.Contains(x.Id))); + }); + StateHasChanged(); + } + } + + private async Task AddGenre() + { + _addLoading = true; + await MediaClientService.PostMediaGenre(Data.Id, _selectedGenre!.Value, () => + { + GenreResponse selectedGenre = _availableGenres.First(x => x.Id == _selectedGenre); + _availableGenres.Remove(selectedGenre); + _chosenGenres[selectedGenre] = false; + _addLoading = false; + _selectedGenre = null; + }); + } + + private async Task RemoveGenre(GenreResponse genre) + { + _chosenGenres[genre] = true; + await MediaClientService.DeleteMediaGenre(Data.Id, genre.Id, () => + { + _chosenGenres.Remove(genre); + _availableGenres.Add(genre); + }); + } + + #endregion +} \ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Components/Pages/UserEditPage/Panels/UserEditPageHeaderPanelComponent.razor b/WatchIt.Website/WatchIt.Website/Components/Pages/UserEditPage/Panels/UserEditPageHeaderPanelComponent.razor index f9a9c48..3b97f34 100644 --- a/WatchIt.Website/WatchIt.Website/Components/Pages/UserEditPage/Panels/UserEditPageHeaderPanelComponent.razor +++ b/WatchIt.Website/WatchIt.Website/Components/Pages/UserEditPage/Panels/UserEditPageHeaderPanelComponent.razor @@ -2,7 +2,7 @@
-

@(AccountData.Username)

+

@(AccountData.Username)

User settings
diff --git a/WatchIt.Website/WatchIt.Website/Components/Pages/UserEditPage/Panels/UserEditPageHeaderPanelComponent.razor.css b/WatchIt.Website/WatchIt.Website/Components/Pages/UserEditPage/Panels/UserEditPageHeaderPanelComponent.razor.css index 7044add..bec8a67 100644 --- a/WatchIt.Website/WatchIt.Website/Components/Pages/UserEditPage/Panels/UserEditPageHeaderPanelComponent.razor.css +++ b/WatchIt.Website/WatchIt.Website/Components/Pages/UserEditPage/Panels/UserEditPageHeaderPanelComponent.razor.css @@ -1,6 +1,6 @@ /* IDS */ -#username { +#primaryText { margin-top: -8px !important; } diff --git a/WatchIt.Website/WatchIt.Website/Pages/GenrePage.razor b/WatchIt.Website/WatchIt.Website/Pages/GenrePage.razor new file mode 100644 index 0000000..6377728 --- /dev/null +++ b/WatchIt.Website/WatchIt.Website/Pages/GenrePage.razor @@ -0,0 +1,54 @@ +@using System.Text +@using WatchIt.Website.Components.Common.ListComponent + +@page "/genre/{id:int}" + +@{ + StringBuilder sb = new StringBuilder(" - WatchIt"); + + if (!_loaded) sb.Insert(0, "Loading..."); + else if (_data is null) sb.Insert(0, "Error"); + else sb.Insert(0, $"\"{_data.Name}\" genre"); + + @(sb.ToString()) +} + + + +@if (!_loaded) +{ +
+ +
+} +else if (_data is null) +{ + +} +else +{ + + + +} \ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Pages/GenrePage.razor.cs b/WatchIt.Website/WatchIt.Website/Pages/GenrePage.razor.cs new file mode 100644 index 0000000..ab19218 --- /dev/null +++ b/WatchIt.Website/WatchIt.Website/Pages/GenrePage.razor.cs @@ -0,0 +1,55 @@ +using Microsoft.AspNetCore.Components; +using WatchIt.Common.Model.Genres; +using WatchIt.Website.Layout; +using WatchIt.Website.Services.Client.Genres; +using WatchIt.Website.Services.Client.Media; + +namespace WatchIt.Website.Pages; + +public partial class GenrePage : ComponentBase +{ + #region SERVICES + + [Inject] private IGenresClientService GenresClientService { get; set; } = default!; + [Inject] private IMediaClientService MediaClientService { get; set; } = default!; + + #endregion + + + + #region PARAMETERS + + [Parameter] public int Id { get; set; } + + [CascadingParameter] public MainLayout Layout { get; set; } + + #endregion + + + + #region FIELDS + + private bool _loaded; + private GenreResponse? _data; + + #endregion + + + + #region PRIVATE METHODS + + protected override async Task OnAfterRenderAsync(bool firstRender) + { + if (firstRender) + { + Layout.BackgroundPhoto = null; + + await GenresClientService.GetGenre(Id, data => _data = data); + + _loaded = true; + StateHasChanged(); + } + } + + #endregion +} \ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Pages/MediaEditPage.razor b/WatchIt.Website/WatchIt.Website/Pages/MediaEditPage.razor index f0aa505..5c827d2 100644 --- a/WatchIt.Website/WatchIt.Website/Pages/MediaEditPage.razor +++ b/WatchIt.Website/WatchIt.Website/Pages/MediaEditPage.razor @@ -1,4 +1,5 @@ -@using Microsoft.IdentityModel.Tokens +@using System.Text +@using Microsoft.IdentityModel.Tokens @using WatchIt.Common.Model.Movies @using WatchIt.Common.Model.Photos @using WatchIt.Common.Model.Series @@ -7,361 +8,319 @@ @page "/media/{id:long}/edit" @page "/media/new/{type?}" +@{ + StringBuilder sb = new StringBuilder(" - WatchIt"); - - WatchIt - - @if (_loaded) + if (!_loaded) sb.Insert(0, "Loading..."); + else if (!string.IsNullOrWhiteSpace(_error) || _user?.IsAdmin != true) sb.Insert(0, "Error"); + else { - if (string.IsNullOrWhiteSpace(_error) && _user?.IsAdmin == true) - { - if (_media is not null) - { - @($"Edit \"")@(_media.Title)@("\"") - } - else - { - if (_movieRequest is null) - { - @("New TV series") - } - else - { - @("New movie") - } - } - } + if (_media is not null) sb.Insert(0, $"Edit \"{_media.Title}\""); else { - @("Error") + if (_movieRequest is null) sb.Insert(0, "TV series"); + else sb.Insert(0, "movie"); + sb.Insert(0, "New "); } } + + @(sb.ToString()) +} + + + +
+ @if (!_loaded) + { +
+ +
+ } + else if (!string.IsNullOrWhiteSpace(_error)) + { + + } + else if (_user?.IsAdmin != true) + { + + } else { - @("Loading") - } - - -
- @if (_loaded) - { - if (string.IsNullOrWhiteSpace(_error)) - { - if (_user?.IsAdmin == true) - { -
-
-
-
- @if (_media is not null) - { - -

Edit @(_movieRequest is not null ? "movie" : "series") "@(_media.Title)"

-
- } - else - { -

Create new @(_movieRequest is not null ? "movie" : "series")

- } + +
+ +
+ + +
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+ +
+ +
+
+ @if (_mediaRequest is MovieRequest) + { +
+ +
+ +
+
+ } + else + { +
+ +
+
+ +
+ + Yes +
+
+ + No +
+
+
+
+
+ } +
+
+
+ @if (!string.IsNullOrWhiteSpace(_basicDataError)) + { +
@_basicDataError
+ } + +
-
-
-
- -
-
-
- - -
-
- -
- -
+ +
+
+ + + Genres + Actors + Creators + Photos + + + + + + + + + + + + +
+
+
+
+
+

Photos

-
- -
- -
-
-
- -
- -
-
-
- -
- -
- -
- -
-
- @if (_mediaRequest is MovieRequest) +
+
+ @if (!_photoEditMode) { -
- -
- -
-
+ } else { -
- -
-
- -
- - Yes -
-
- - No -
-
-
-
-
- } -
-
-
- @if (!string.IsNullOrWhiteSpace(_basicDataError)) - { -
@_basicDataError
- } - -
-
-
-
- -
-
-
-
-
- -
-
-
-
- -
-
-
-
-
-
-
-
-
-

Photos

-
-
-
- @if (!_photoEditMode) +
+ @if (!string.IsNullOrWhiteSpace(_photoEditError)) { - +
+ @_photoEditError +
} - else - { -
- @if (!string.IsNullOrWhiteSpace(_photoEditError)) - { -
- @_photoEditError -
- } - - -
- } -
-
-
-
- @if (!_photoEditMode) - { - if (!_photos.IsNullOrEmpty()) + -
-
- -
-
-
- } -
+ Save } else { -
- Photo list is empty -
+ + Saving... } - } - else + + +
+ } +
+
+
+
+ @if (!_photoEditMode) + { + if (!_photos.IsNullOrEmpty()) + { +
+ @foreach (PhotoResponse photo in _photos) { -
-
-
-
-
-
- -
-
- @if (_photoEditId is null) - { -
-
- -
-
- } +
+
+
+ +
+
+
+ @if (photo.Background is not null) + { +
+
+
+ background_icon
-
-
-
-
-
- - -
-
-
-
- - -
-
+
+ } +
+
+ Upload: @(photo.UploadDate.ToString()) +
+
+
+ +
+
+ +
+
+
+ } +
+ } + else + { +
+ Photo list is empty +
+ } + } + else + { +
+
+
+
+
+
+ +
+
+ @if (_photoEditId is null) + { +
+
+ +
+
+ } +
+
+
+
+
+
+
+ +
-
- -
- -
-
-
- -
- -
+
+
+
+ +
+
+ +
+ +
+
+
+ +
+ +
+
- } +
+ }
-
- } - else - { -
-
- -
-
- } - } - else - { -
-
- -
-
- } - } - else - { -
-
-
- -
-
-
+ + + }
\ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Program.cs b/WatchIt.Website/WatchIt.Website/Program.cs index fe0c437..f2fbd67 100644 --- a/WatchIt.Website/WatchIt.Website/Program.cs +++ b/WatchIt.Website/WatchIt.Website/Program.cs @@ -10,6 +10,7 @@ using WatchIt.Website.Services.Configuration; using WatchIt.Website.Services.Tokens; using WatchIt.Website.Services.Client.Accounts; using WatchIt.Website.Services.Client.Genders; +using WatchIt.Website.Services.Client.Genres; using WatchIt.Website.Services.Client.Media; using WatchIt.Website.Services.Client.Movies; using WatchIt.Website.Services.Client.Persons; @@ -75,6 +76,7 @@ public static class Program // WebAPI builder.Services.AddScoped(); builder.Services.AddSingleton(); + builder.Services.AddSingleton(); builder.Services.AddSingleton(); builder.Services.AddSingleton(); builder.Services.AddSingleton(); diff --git a/WatchIt.Website/WatchIt.Website/appsettings.json b/WatchIt.Website/WatchIt.Website/appsettings.json index 9f2429a..5123a91 100644 --- a/WatchIt.Website/WatchIt.Website/appsettings.json +++ b/WatchIt.Website/WatchIt.Website/appsettings.json @@ -46,11 +46,12 @@ }, "Genres": { "Base": "/genres", - "GetAll": "", - "Get": "/{0}", - "Post": "", - "Put": "/{0}", - "Delete": "/{0}" + "GetGenres": "", + "GetGenre": "/{0}", + "PostGenre": "", + "PutGenre": "/{0}", + "DeleteGenre": "/{0}", + "GetGenreMedia": "/{0}/media" }, "Media": { "Base": "/media",