diff --git a/WatchIt.Common/WatchIt.Common.Model/Genres/GenreResponse.cs b/WatchIt.Common/WatchIt.Common.Model/Genres/GenreResponse.cs index 022fa80..9bb7cba 100644 --- a/WatchIt.Common/WatchIt.Common.Model/Genres/GenreResponse.cs +++ b/WatchIt.Common/WatchIt.Common.Model/Genres/GenreResponse.cs @@ -18,7 +18,7 @@ public class GenreResponse : Genre, IQueryOrderable [JsonPropertyName("id")] - public long Id { get; set; } + public short Id { get; set; } #endregion diff --git a/WatchIt.Common/WatchIt.Common.Model/Media/MediaQueryParameters.cs b/WatchIt.Common/WatchIt.Common.Model/Media/MediaQueryParameters.cs index fcbfe10..b0952b0 100644 --- a/WatchIt.Common/WatchIt.Common.Model/Media/MediaQueryParameters.cs +++ b/WatchIt.Common/WatchIt.Common.Model/Media/MediaQueryParameters.cs @@ -54,6 +54,9 @@ public class MediaQueryParameters : QueryParameters [FromQuery(Name = "rating_count_to")] public long? RatingCountTo { get; set; } + + [FromQuery(Name = "genre")] + public IEnumerable? Genres { get; set; } #endregion @@ -78,6 +81,8 @@ public class MediaQueryParameters : QueryParameters TestComparable(item.Rating.Average, RatingAverage, RatingAverageFrom, RatingAverageTo) && TestComparable(item.Rating.Count, RatingCount, RatingCountFrom, RatingCountTo) + && + TestContains(Genres, item.Genres.Select(x => x.Id)) ); #endregion diff --git a/WatchIt.Common/WatchIt.Common.Model/Media/MediaResponse.cs b/WatchIt.Common/WatchIt.Common.Model/Media/MediaResponse.cs index fd10ae8..8a18de1 100644 --- a/WatchIt.Common/WatchIt.Common.Model/Media/MediaResponse.cs +++ b/WatchIt.Common/WatchIt.Common.Model/Media/MediaResponse.cs @@ -1,5 +1,6 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json.Serialization; +using WatchIt.Common.Model.Genres; using WatchIt.Common.Model.Rating; using WatchIt.Common.Query; @@ -31,6 +32,9 @@ public class MediaResponse : Media, IQueryOrderable [JsonPropertyName("rating")] public RatingResponse Rating { get; set; } + + [JsonPropertyName("genres")] + public IEnumerable Genres { get; set; } #endregion @@ -52,6 +56,7 @@ public class MediaResponse : Media, IQueryOrderable Length = media.Length; Type = mediaType; Rating = RatingResponse.Create(media.RatingMedia); + Genres = media.Genres.Select(x => new GenreResponse(x)).ToList(); } #endregion diff --git a/WatchIt.Common/WatchIt.Common.Model/Movies/MovieQueryParameters.cs b/WatchIt.Common/WatchIt.Common.Model/Movies/MovieQueryParameters.cs index ede62e0..35c239c 100644 --- a/WatchIt.Common/WatchIt.Common.Model/Movies/MovieQueryParameters.cs +++ b/WatchIt.Common/WatchIt.Common.Model/Movies/MovieQueryParameters.cs @@ -60,6 +60,9 @@ public class MovieQueryParameters : QueryParameters [FromQuery(Name = "rating_count_to")] public long? RatingCountTo { get; set; } + + [FromQuery(Name = "genre")] + public IEnumerable? Genres { get; set; } #endregion @@ -84,6 +87,8 @@ public class MovieQueryParameters : QueryParameters TestComparable(item.Rating.Average, RatingAverage, RatingAverageFrom, RatingAverageTo) && TestComparable(item.Rating.Count, RatingCount, RatingCountFrom, RatingCountTo) + && + TestContains(item.Genres.Select(x => x.Id), Genres) ); #endregion diff --git a/WatchIt.Common/WatchIt.Common.Model/Movies/MovieRatedQueryParameters.cs b/WatchIt.Common/WatchIt.Common.Model/Movies/MovieRatedQueryParameters.cs new file mode 100644 index 0000000..ef74767 --- /dev/null +++ b/WatchIt.Common/WatchIt.Common.Model/Movies/MovieRatedQueryParameters.cs @@ -0,0 +1,104 @@ +using Microsoft.AspNetCore.Mvc; +using WatchIt.Common.Query; + +namespace WatchIt.Common.Model.Movies; + +public class MovieRatedQueryParameters : QueryParameters +{ + #region PROPERTIES + + [FromQuery(Name = "title")] + public string? Title { get; set; } + + [FromQuery(Name = "original_title")] + public string? OriginalTitle { get; set; } + + [FromQuery(Name = "description")] + public string? Description { get; set; } + + [FromQuery(Name = "release_date")] + public DateOnly? ReleaseDate { get; set; } + + [FromQuery(Name = "release_date_from")] + public DateOnly? ReleaseDateFrom { get; set; } + + [FromQuery(Name = "release_date_to")] + public DateOnly? ReleaseDateTo { get; set; } + + [FromQuery(Name = "length")] + public short? Length { get; set; } + + [FromQuery(Name = "length_from")] + public short? LengthFrom { get; set; } + + [FromQuery(Name = "length_to")] + public short? LengthTo { get; set; } + + [FromQuery(Name = "budget")] + public decimal? Budget { get; set; } + + [FromQuery(Name = "budget_from")] + public decimal? BudgetFrom { get; set; } + + [FromQuery(Name = "budget_to")] + public decimal? BudgetTo { get; set; } + + [FromQuery(Name = "rating_average")] + public decimal? RatingAverage { get; set; } + + [FromQuery(Name = "rating_average_from")] + public decimal? RatingAverageFrom { get; set; } + + [FromQuery(Name = "rating_average_to")] + public decimal? RatingAverageTo { get; set; } + + [FromQuery(Name = "rating_count")] + public long? RatingCount { get; set; } + + [FromQuery(Name = "rating_count_from")] + public long? RatingCountFrom { get; set; } + + [FromQuery(Name = "rating_count_to")] + public long? RatingCountTo { get; set; } + + [FromQuery(Name = "genre")] + public IEnumerable? Genres { get; set; } + + [FromQuery(Name = "user_rating")] + public decimal? UserRating { get; set; } + + [FromQuery(Name = "user_rating_from")] + public decimal? UserRatingFrom { get; set; } + + [FromQuery(Name = "user_rating_to")] + public decimal? UserRatingTo { get; set; } + + #endregion + + + + #region PRIVATE METHODS + + protected override bool IsMeetingConditions(MovieRatedResponse item) => + ( + TestStringWithRegex(item.Title, Title) + && + TestStringWithRegex(item.OriginalTitle, OriginalTitle) + && + TestStringWithRegex(item.Description, Description) + && + TestComparable(item.ReleaseDate, ReleaseDate, ReleaseDateFrom, ReleaseDateTo) + && + TestComparable(item.Length, Length, LengthFrom, LengthTo) + && + TestComparable(item.Rating.Average, RatingAverage, RatingAverageFrom, RatingAverageTo) + && + TestComparable(item.Rating.Count, RatingCount, RatingCountFrom, RatingCountTo) + && + TestContains(Genres, item.Genres.Select(x => x.Id)) + && + TestComparable((decimal)item.UserRating, UserRating, UserRatingFrom, UserRatingTo) + ); + + #endregion +} \ No newline at end of file diff --git a/WatchIt.Common/WatchIt.Common.Model/Movies/MovieRatedResponse.cs b/WatchIt.Common/WatchIt.Common.Model/Movies/MovieRatedResponse.cs new file mode 100644 index 0000000..0e1bd31 --- /dev/null +++ b/WatchIt.Common/WatchIt.Common.Model/Movies/MovieRatedResponse.cs @@ -0,0 +1,58 @@ +using System.Diagnostics.CodeAnalysis; +using System.Text.Json.Serialization; +using WatchIt.Common.Model.Genres; +using WatchIt.Common.Model.Rating; +using WatchIt.Common.Query; +using WatchIt.Database.Model.Media; +using WatchIt.Database.Model.Rating; + +namespace WatchIt.Common.Model.Movies; + +public class MovieRatedResponse : MovieResponse, IQueryOrderable +{ + #region PROPERTIES + + [JsonIgnore] + public static IDictionary> OrderableProperties { get; } = new Dictionary> + { + { "id", x => x.Id }, + { "title", x => x.Title }, + { "original_title", x => x.OriginalTitle }, + { "description", x => x.Description }, + { "release_date", x => x.ReleaseDate }, + { "length", x => x.Length }, + { "budget", x => x.Budget }, + { "rating.average", x => x.Rating.Average }, + { "rating.count", x => x.Rating.Count }, + { "user_rating", x => x.UserRating } + }; + + [JsonPropertyName("user_rating")] + public short UserRating { get; set; } + + #endregion + + + + #region CONSTRUCTORS + + [JsonConstructor] + public MovieRatedResponse() { } + + [SetsRequiredMembers] + public MovieRatedResponse(MediaMovie mediaMovie, RatingMedia response) + { + Id = mediaMovie.Media.Id; + Title = mediaMovie.Media.Title; + OriginalTitle = mediaMovie.Media.OriginalTitle; + Description = mediaMovie.Media.Description; + ReleaseDate = mediaMovie.Media.ReleaseDate; + Length = mediaMovie.Media.Length; + Budget = mediaMovie.Budget; + Rating = RatingResponse.Create(mediaMovie.Media.RatingMedia); + Genres = mediaMovie.Media.Genres.Select(x => new GenreResponse(x)).ToList(); + UserRating = response.Rating; + } + + #endregion +} \ No newline at end of file diff --git a/WatchIt.Common/WatchIt.Common.Model/Movies/MovieResponse.cs b/WatchIt.Common/WatchIt.Common.Model/Movies/MovieResponse.cs index 366b058..2e25288 100644 --- a/WatchIt.Common/WatchIt.Common.Model/Movies/MovieResponse.cs +++ b/WatchIt.Common/WatchIt.Common.Model/Movies/MovieResponse.cs @@ -1,5 +1,6 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json.Serialization; +using WatchIt.Common.Model.Genres; using WatchIt.Common.Model.Rating; using WatchIt.Common.Query; using WatchIt.Database.Model.Media; @@ -30,6 +31,9 @@ public class MovieResponse : Movie, IQueryOrderable [JsonPropertyName("rating")] public RatingResponse Rating { get; set; } + + [JsonPropertyName("genres")] + public IEnumerable Genres { get; set; } #endregion @@ -51,6 +55,7 @@ public class MovieResponse : Movie, IQueryOrderable Length = mediaMovie.Media.Length; Budget = mediaMovie.Budget; Rating = RatingResponse.Create(mediaMovie.Media.RatingMedia); + Genres = mediaMovie.Media.Genres.Select(x => new GenreResponse(x)).ToList(); } #endregion diff --git a/WatchIt.Common/WatchIt.Common.Model/Series/SeriesQueryParameters.cs b/WatchIt.Common/WatchIt.Common.Model/Series/SeriesQueryParameters.cs index 164a029..2cc5de4 100644 --- a/WatchIt.Common/WatchIt.Common.Model/Series/SeriesQueryParameters.cs +++ b/WatchIt.Common/WatchIt.Common.Model/Series/SeriesQueryParameters.cs @@ -54,6 +54,9 @@ public class SeriesQueryParameters : QueryParameters [FromQuery(Name = "rating_count_to")] public long? RatingCountTo { get; set; } + + [FromQuery(Name = "genre")] + public IEnumerable? Genres { get; set; } #endregion @@ -78,6 +81,8 @@ public class SeriesQueryParameters : QueryParameters TestComparable(item.Rating.Average, RatingAverage, RatingAverageFrom, RatingAverageTo) && TestComparable(item.Rating.Count, RatingCount, RatingCountFrom, RatingCountTo) + && + TestContains(item.Genres.Select(x => x.Id), Genres) ); #endregion diff --git a/WatchIt.Common/WatchIt.Common.Model/Series/SeriesRatedQueryParameters.cs b/WatchIt.Common/WatchIt.Common.Model/Series/SeriesRatedQueryParameters.cs new file mode 100644 index 0000000..7d155ab --- /dev/null +++ b/WatchIt.Common/WatchIt.Common.Model/Series/SeriesRatedQueryParameters.cs @@ -0,0 +1,100 @@ +using Microsoft.AspNetCore.Mvc; +using WatchIt.Common.Query; + +namespace WatchIt.Common.Model.Series; + +public class SeriesRatedQueryParameters : QueryParameters +{ + #region PROPERTIES + + [FromQuery(Name = "title")] + public string? Title { get; set; } + + [FromQuery(Name = "original_title")] + public string? OriginalTitle { get; set; } + + [FromQuery(Name = "description")] + public string? Description { get; set; } + + [FromQuery(Name = "release_date")] + public DateOnly? ReleaseDate { get; set; } + + [FromQuery(Name = "release_date_from")] + public DateOnly? ReleaseDateFrom { get; set; } + + [FromQuery(Name = "release_date_to")] + public DateOnly? ReleaseDateTo { get; set; } + + [FromQuery(Name = "length")] + public short? Length { get; set; } + + [FromQuery(Name = "length_from")] + public short? LengthFrom { get; set; } + + [FromQuery(Name = "length_to")] + public short? LengthTo { get; set; } + + [FromQuery(Name = "has_ended")] + public bool? HasEnded { get; set; } + + [FromQuery(Name = "rating_average")] + public decimal? RatingAverage { get; set; } + + [FromQuery(Name = "rating_average_from")] + public decimal? RatingAverageFrom { get; set; } + + [FromQuery(Name = "rating_average_to")] + public decimal? RatingAverageTo { get; set; } + + [FromQuery(Name = "rating_count")] + public long? RatingCount { get; set; } + + [FromQuery(Name = "rating_count_from")] + public long? RatingCountFrom { get; set; } + + [FromQuery(Name = "rating_count_to")] + public long? RatingCountTo { get; set; } + + [FromQuery(Name = "genre")] + public IEnumerable? Genres { get; set; } + + [FromQuery(Name = "user_rating")] + public decimal? UserRating { get; set; } + + [FromQuery(Name = "user_rating_from")] + public decimal? UserRatingFrom { get; set; } + + [FromQuery(Name = "user_rating_to")] + public decimal? UserRatingTo { get; set; } + + #endregion + + + + #region PRIVATE METHODS + + protected override bool IsMeetingConditions(SeriesRatedResponse item) => + ( + TestStringWithRegex(item.Title, Title) + && + TestStringWithRegex(item.OriginalTitle, OriginalTitle) + && + TestStringWithRegex(item.Description, Description) + && + TestComparable(item.ReleaseDate, ReleaseDate, ReleaseDateFrom, ReleaseDateTo) + && + TestComparable(item.Length, Length, LengthFrom, LengthTo) + && + Test(item.HasEnded, HasEnded) + && + TestComparable(item.Rating.Average, RatingAverage, RatingAverageFrom, RatingAverageTo) + && + TestComparable(item.Rating.Count, RatingCount, RatingCountFrom, RatingCountTo) + && + TestContains(item.Genres.Select(x => x.Id), Genres) + && + TestComparable((decimal)item.UserRating, UserRating, UserRatingFrom, UserRatingTo) + ); + + #endregion +} \ No newline at end of file diff --git a/WatchIt.Common/WatchIt.Common.Model/Series/SeriesRatedResponse.cs b/WatchIt.Common/WatchIt.Common.Model/Series/SeriesRatedResponse.cs new file mode 100644 index 0000000..2e47804 --- /dev/null +++ b/WatchIt.Common/WatchIt.Common.Model/Series/SeriesRatedResponse.cs @@ -0,0 +1,58 @@ +using System.Diagnostics.CodeAnalysis; +using System.Text.Json.Serialization; +using WatchIt.Common.Model.Genres; +using WatchIt.Common.Model.Rating; +using WatchIt.Common.Query; +using WatchIt.Database.Model.Media; +using WatchIt.Database.Model.Rating; + +namespace WatchIt.Common.Model.Series; + +public class SeriesRatedResponse : SeriesResponse, IQueryOrderable +{ + #region PROPERTIES + + [JsonIgnore] + public static IDictionary> OrderableProperties { get; } = new Dictionary> + { + { "id", x => x.Id }, + { "title", x => x.Title }, + { "original_title", x => x.OriginalTitle }, + { "description", x => x.Description }, + { "release_date", x => x.ReleaseDate }, + { "length", x => x.Length }, + { "has_ended", x => x.HasEnded }, + { "rating.average", x => x.Rating.Average }, + { "rating.count", x => x.Rating.Count }, + { "user_rating", x => x.UserRating } + }; + + [JsonPropertyName("user_rating")] + public short UserRating { get; set; } + + #endregion + + + + #region CONSTRUCTORS + + [JsonConstructor] + public SeriesRatedResponse() { } + + [SetsRequiredMembers] + public SeriesRatedResponse(MediaSeries mediaSeries, RatingMedia response) + { + Id = mediaSeries.Media.Id; + Title = mediaSeries.Media.Title; + OriginalTitle = mediaSeries.Media.OriginalTitle; + Description = mediaSeries.Media.Description; + ReleaseDate = mediaSeries.Media.ReleaseDate; + Length = mediaSeries.Media.Length; + HasEnded = mediaSeries.HasEnded; + Rating = RatingResponse.Create(mediaSeries.Media.RatingMedia); + Genres = mediaSeries.Media.Genres.Select(x => new GenreResponse(x)).ToList(); + UserRating = response.Rating; + } + + #endregion +} \ No newline at end of file diff --git a/WatchIt.Common/WatchIt.Common.Model/Series/SeriesResponse.cs b/WatchIt.Common/WatchIt.Common.Model/Series/SeriesResponse.cs index fe3fa4b..17a0f9d 100644 --- a/WatchIt.Common/WatchIt.Common.Model/Series/SeriesResponse.cs +++ b/WatchIt.Common/WatchIt.Common.Model/Series/SeriesResponse.cs @@ -1,5 +1,6 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json.Serialization; +using WatchIt.Common.Model.Genres; using WatchIt.Common.Model.Rating; using WatchIt.Common.Query; using WatchIt.Database.Model.Media; @@ -30,6 +31,9 @@ public class SeriesResponse : Series, IQueryOrderable [JsonPropertyName("rating")] public RatingResponse Rating { get; set; } + + [JsonPropertyName("genres")] + public IEnumerable Genres { get; set; } #endregion @@ -51,6 +55,7 @@ public class SeriesResponse : Series, IQueryOrderable Length = mediaSeries.Media.Length; HasEnded = mediaSeries.HasEnded; Rating = RatingResponse.Create(mediaSeries.Media.RatingMedia); + Genres = mediaSeries.Media.Genres.Select(x => new GenreResponse(x)).ToList(); } #endregion diff --git a/WatchIt.Common/WatchIt.Common.Query/QueryParameters.cs b/WatchIt.Common/WatchIt.Common.Query/QueryParameters.cs index c574197..4f27d62 100644 --- a/WatchIt.Common/WatchIt.Common.Query/QueryParameters.cs +++ b/WatchIt.Common/WatchIt.Common.Query/QueryParameters.cs @@ -1,4 +1,5 @@ -using System.Globalization; +using System.Collections; +using System.Globalization; using System.Reflection; using System.Text; using System.Text.Json.Serialization; @@ -39,13 +40,16 @@ public abstract class QueryParameters FromQueryAttribute? attribute = property.GetCustomAttributes(true).FirstOrDefault(); if (value is not null && attribute is not null) { - string valueString = (value switch + if (value is IEnumerable enumerable and not string) { - decimal d => d.ToString(CultureInfo.InvariantCulture), - _ => value.ToString() - })!; - string query = $"{attribute.Name}={valueString}"; - queries.Add(query); + IEnumerable arrayQueryElements = enumerable.Cast().Select(x => QueryElementToString(attribute.Name!, x.ToString())); + queries.AddRange(arrayQueryElements); + } + else + { + string query = QueryElementToString(attribute.Name!, value); + queries.Add(query); + } } } @@ -58,6 +62,18 @@ public abstract class QueryParameters #region PRIVATE METHODS + private string QueryElementToString(string name, object value) + { + string valueString = (value switch + { + decimal d => d.ToString(CultureInfo.InvariantCulture), + _ => value.ToString() + })!; + string query = $"{name}={valueString}"; + return query; + } + + protected static bool Test(T? property, T? query) => ( query is null @@ -113,6 +129,15 @@ public abstract class QueryParameters ) ); + protected static bool TestContains(IEnumerable? shouldBeInCollection, IEnumerable? collection) => + ( + collection is null + || + shouldBeInCollection is null + || + shouldBeInCollection.All(collection.Contains) + ); + #endregion } diff --git a/WatchIt.WebAPI/WatchIt.WebAPI.Controllers/AccountsController.cs b/WatchIt.WebAPI/WatchIt.WebAPI.Controllers/AccountsController.cs index c431396..1fceee4 100644 --- a/WatchIt.WebAPI/WatchIt.WebAPI.Controllers/AccountsController.cs +++ b/WatchIt.WebAPI/WatchIt.WebAPI.Controllers/AccountsController.cs @@ -3,6 +3,8 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using WatchIt.Common.Model.Accounts; +using WatchIt.Common.Model.Movies; +using WatchIt.Common.Model.Series; using WatchIt.WebAPI.Services.Controllers.Accounts; namespace WatchIt.WebAPI.Controllers; @@ -49,17 +51,22 @@ public class AccountsController(IAccountsControllerService accountsControllerSer [ProducesResponseType(StatusCodes.Status404NotFound)] public async Task GetAccountInfo([FromRoute]long id) => await accountsControllerService.GetAccountInfo(id); - [HttpGet("info")] - [Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)] - [ProducesResponseType(typeof(AccountResponse), StatusCodes.Status200OK)] - [ProducesResponseType(StatusCodes.Status401Unauthorized)] - [ProducesResponseType(StatusCodes.Status404NotFound)] - public async Task GetAccountInfo() => await accountsControllerService.GetAccountInfo(); - [HttpPut("info")] [Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)] [ProducesResponseType(typeof(AccountResponse), StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status401Unauthorized)] [ProducesResponseType(StatusCodes.Status404NotFound)] public async Task PutAccountInfo([FromBody]AccountRequest data) => await accountsControllerService.PutAccountInfo(data); + + [HttpGet("{id}/movies")] + [AllowAnonymous] + [ProducesResponseType(typeof(IEnumerable), StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status404NotFound)] + public async Task GetAccountRatedMovies([FromRoute]long id, MovieRatedQueryParameters query) => await accountsControllerService.GetAccountRatedMovies(id, query); + + [HttpGet("{id}/series")] + [AllowAnonymous] + [ProducesResponseType(typeof(IEnumerable), StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status404NotFound)] + public async Task GetAccountRatedSeries([FromRoute]long id, SeriesRatedQueryParameters query) => await accountsControllerService.GetAccountRatedSeries(id, query); } \ No newline at end of file diff --git a/WatchIt.WebAPI/WatchIt.WebAPI.Services/WatchIt.WebAPI.Services.Controllers/WatchIt.WebAPI.Services.Controllers.Accounts/AccountsControllerService.cs b/WatchIt.WebAPI/WatchIt.WebAPI.Services/WatchIt.WebAPI.Services.Controllers/WatchIt.WebAPI.Services.Controllers.Accounts/AccountsControllerService.cs index af69597..f49a9be 100644 --- a/WatchIt.WebAPI/WatchIt.WebAPI.Services/WatchIt.WebAPI.Services.Controllers/WatchIt.WebAPI.Services.Controllers.Accounts/AccountsControllerService.cs +++ b/WatchIt.WebAPI/WatchIt.WebAPI.Services/WatchIt.WebAPI.Services.Controllers/WatchIt.WebAPI.Services.Controllers.Accounts/AccountsControllerService.cs @@ -5,8 +5,13 @@ using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Logging; using SimpleToolkit.Extensions; using WatchIt.Common.Model.Accounts; +using WatchIt.Common.Model.Media; +using WatchIt.Common.Model.Movies; +using WatchIt.Common.Model.Series; using WatchIt.Database; using WatchIt.Database.Model.Account; +using WatchIt.Database.Model.Media; +using WatchIt.Database.Model.Rating; using WatchIt.WebAPI.Services.Controllers.Common; using WatchIt.WebAPI.Services.Utility.Tokens; using WatchIt.WebAPI.Services.Utility.Tokens.Exceptions; @@ -136,7 +141,6 @@ public class AccountsControllerService( return RequestResult.Ok(picture); } - public async Task GetAccountInfo() => await GetAccountInfo(userService.GetUserId()); public async Task GetAccountInfo(long id) { Account? account = await database.Accounts.FirstOrDefaultAsync(x => x.Id == id); @@ -160,6 +164,32 @@ public class AccountsControllerService( data.UpdateAccount(account); return RequestResult.Ok(); } + + public async Task GetAccountRatedMovies(long id, MovieRatedQueryParameters query) + { + Account? account = await database.Accounts.FirstOrDefaultAsync(x => x.Id == id); + if (account is null) + { + return RequestResult.NotFound(); + } + + IEnumerable response = account.RatingMedia.Join(database.MediaMovies, x => x.MediaId, x => x.Id, (x, y) => new MovieRatedResponse(y, x)); + response = query.PrepareData(response); + return RequestResult.Ok(response); + } + + public async Task GetAccountRatedSeries(long id, SeriesRatedQueryParameters query) + { + Account? account = await database.Accounts.FirstOrDefaultAsync(x => x.Id == id); + if (account is null) + { + return RequestResult.NotFound(); + } + + IEnumerable response = account.RatingMedia.Join(database.MediaSeries, x => x.MediaId, x => x.Id, (x, y) => new SeriesRatedResponse(y, x)); + response = query.PrepareData(response); + return RequestResult.Ok(response); + } #endregion diff --git a/WatchIt.WebAPI/WatchIt.WebAPI.Services/WatchIt.WebAPI.Services.Controllers/WatchIt.WebAPI.Services.Controllers.Accounts/IAccountsControllerService.cs b/WatchIt.WebAPI/WatchIt.WebAPI.Services/WatchIt.WebAPI.Services.Controllers/WatchIt.WebAPI.Services.Controllers.Accounts/IAccountsControllerService.cs index 03098fe..5ce20dd 100644 --- a/WatchIt.WebAPI/WatchIt.WebAPI.Services/WatchIt.WebAPI.Services.Controllers/WatchIt.WebAPI.Services.Controllers.Accounts/IAccountsControllerService.cs +++ b/WatchIt.WebAPI/WatchIt.WebAPI.Services/WatchIt.WebAPI.Services.Controllers/WatchIt.WebAPI.Services.Controllers.Accounts/IAccountsControllerService.cs @@ -1,4 +1,7 @@ using WatchIt.Common.Model.Accounts; +using WatchIt.Common.Model.Media; +using WatchIt.Common.Model.Movies; +using WatchIt.Common.Model.Series; using WatchIt.WebAPI.Services.Controllers.Common; namespace WatchIt.WebAPI.Services.Controllers.Accounts; @@ -10,7 +13,8 @@ public interface IAccountsControllerService Task AuthenticateRefresh(); Task Logout(); Task GetAccountProfilePicture(long id); - Task GetAccountInfo(); Task GetAccountInfo(long id); Task PutAccountInfo(AccountRequest data); + Task GetAccountRatedMovies(long id, MovieRatedQueryParameters query); + Task GetAccountRatedSeries(long id, SeriesRatedQueryParameters query); } \ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.Client/Accounts/AccountsClientService.cs b/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.Client/Accounts/AccountsClientService.cs index 70b6ccd..d71bb0f 100644 --- a/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.Client/Accounts/AccountsClientService.cs +++ b/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.Client/Accounts/AccountsClientService.cs @@ -1,4 +1,6 @@ using WatchIt.Common.Model.Accounts; +using WatchIt.Common.Model.Movies; +using WatchIt.Common.Model.Series; using WatchIt.Common.Services.HttpClient; using WatchIt.Website.Services.Configuration; using WatchIt.Website.Services.Tokens; @@ -78,9 +80,9 @@ public class AccountsClientService(IHttpClientService httpClientService, IConfig .ExecuteAction(); } - public async Task GetAccountInfoById(long id, Action? successAction = null, Action? notFoundAction = null) + public async Task GetAccountInfo(long id, Action? successAction = null, Action? notFoundAction = null) { - string url = GetUrl(EndpointsConfiguration.Accounts.GetAccountInfoById, id); + string url = GetUrl(EndpointsConfiguration.Accounts.GetAccountInfo, id); HttpRequest request = new HttpRequest(HttpMethodType.Get, url); HttpResponse response = await httpClientService.SendRequestAsync(request); @@ -89,18 +91,6 @@ public class AccountsClientService(IHttpClientService httpClientService, IConfig .ExecuteAction(); } - public async Task GetAccountInfo(Action? successAction = null, Action? unauthorizedAction = null, Action? notFoundAction = null) - { - string url = GetUrl(EndpointsConfiguration.Accounts.GetAccountInfo); - HttpRequest request = new HttpRequest(HttpMethodType.Get, url); - - HttpResponse response = await httpClientService.SendRequestAsync(request); - response.RegisterActionFor2XXSuccess(successAction) - .RegisterActionFor401Unauthorized(unauthorizedAction) - .RegisterActionFor404NotFound(notFoundAction) - .ExecuteAction(); - } - public async Task PutAccountInfo(AccountRequest data, Action? successAction = null, Action>? badRequestAction = null, Action? unauthorizedAction = null, Action? notFoundAction = null) { string url = GetUrl(EndpointsConfiguration.Accounts.PutAccountInfo); @@ -117,6 +107,34 @@ public class AccountsClientService(IHttpClientService httpClientService, IConfig .ExecuteAction(); } + public async Task GetAccountRatedMovies(long id, MovieRatedQueryParameters query, Action>? successAction = null, Action? notFoundAction = null) + { + string url = GetUrl(EndpointsConfiguration.Accounts.GetAccountRatedMovies, id); + HttpRequest request = new HttpRequest(HttpMethodType.Get, url) + { + Query = query + }; + + HttpResponse response = await httpClientService.SendRequestAsync(request); + response.RegisterActionFor2XXSuccess(successAction) + .RegisterActionFor404NotFound(notFoundAction) + .ExecuteAction(); + } + + public async Task GetAccountRatedSeries(long id, SeriesRatedQueryParameters query, Action>? successAction = null, Action? notFoundAction = null) + { + string url = GetUrl(EndpointsConfiguration.Accounts.GetAccountRatedSeries, id); + HttpRequest request = new HttpRequest(HttpMethodType.Get, url) + { + Query = query + }; + + HttpResponse response = await httpClientService.SendRequestAsync(request); + response.RegisterActionFor2XXSuccess(successAction) + .RegisterActionFor404NotFound(notFoundAction) + .ExecuteAction(); + } + #endregion diff --git a/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.Client/Accounts/IAccountsClientService.cs b/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.Client/Accounts/IAccountsClientService.cs index 9410526..7a2b0d7 100644 --- a/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.Client/Accounts/IAccountsClientService.cs +++ b/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.Client/Accounts/IAccountsClientService.cs @@ -1,4 +1,6 @@ using WatchIt.Common.Model.Accounts; +using WatchIt.Common.Model.Movies; +using WatchIt.Common.Model.Series; namespace WatchIt.Website.Services.Client.Accounts; @@ -9,7 +11,8 @@ public interface IAccountsClientService Task AuthenticateRefresh(Action? successAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null); Task Logout(Action? successAction = null); Task GetAccountProfilePicture(long id, Action? successAction = null, Action>? badRequestAction = null, Action? notFoundAction = null); - Task GetAccountInfoById(long id, Action? successAction = null, Action? notFoundAction = null); - Task GetAccountInfo(Action? successAction = null, Action? unauthorizedAction = null, Action? notFoundAction = null); + Task GetAccountInfo(long id, Action? successAction = null, Action? notFoundAction = null); Task PutAccountInfo(AccountRequest data, Action? successAction = null, Action>? badRequestAction = null, Action? unauthorizedAction = null, Action? notFoundAction = null); + Task GetAccountRatedMovies(long id, MovieRatedQueryParameters query, Action>? successAction = null, Action? notFoundAction = null); + Task GetAccountRatedSeries(long id, SeriesRatedQueryParameters query, 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/Accounts.cs b/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.Configuration/Model/Accounts.cs index 1f648cf..9487bce 100644 --- a/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.Configuration/Model/Accounts.cs +++ b/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.Configuration/Model/Accounts.cs @@ -8,7 +8,8 @@ public class Accounts public string AuthenticateRefresh { get; set; } public string Logout { get; set; } public string GetProfilePicture { get; set; } - public string GetAccountInfoById { get; set; } public string GetAccountInfo { get; set; } public string PutAccountInfo { get; set; } + public string GetAccountRatedMovies { get; set; } + public string GetAccountRatedSeries { get; set; } } \ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/App.razor b/WatchIt.Website/WatchIt.Website/App.razor index 502723d..fda64f7 100644 --- a/WatchIt.Website/WatchIt.Website/App.razor +++ b/WatchIt.Website/WatchIt.Website/App.razor @@ -13,7 +13,7 @@ - + diff --git a/WatchIt.Website/WatchIt.Website/Components/Pages/DatabasePage/Subcomponents/FilterFormComponent.cs b/WatchIt.Website/WatchIt.Website/Components/Common/ListComponent/FilterFormComponent.cs similarity index 73% rename from WatchIt.Website/WatchIt.Website/Components/Pages/DatabasePage/Subcomponents/FilterFormComponent.cs rename to WatchIt.Website/WatchIt.Website/Components/Common/ListComponent/FilterFormComponent.cs index 1df000c..19fa363 100644 --- a/WatchIt.Website/WatchIt.Website/Components/Pages/DatabasePage/Subcomponents/FilterFormComponent.cs +++ b/WatchIt.Website/WatchIt.Website/Components/Common/ListComponent/FilterFormComponent.cs @@ -1,14 +1,14 @@ using Microsoft.AspNetCore.Components; using WatchIt.Common.Query; -namespace WatchIt.Website.Components.Pages.DatabasePage.Subcomponents; +namespace WatchIt.Website.Components.Common.ListComponent; public abstract class FilterFormComponent : ComponentBase where TItem : IQueryOrderable where TQuery : QueryParameters { #region PARAMETERS [CascadingParameter] - protected DatabasePageComponent Parent { get; set; } + protected ListComponent Parent { get; set; } #endregion diff --git a/WatchIt.Website/WatchIt.Website/Components/Pages/DatabasePage/DatabasePageComponent.razor b/WatchIt.Website/WatchIt.Website/Components/Common/ListComponent/ListComponent.razor similarity index 96% rename from WatchIt.Website/WatchIt.Website/Components/Pages/DatabasePage/DatabasePageComponent.razor rename to WatchIt.Website/WatchIt.Website/Components/Common/ListComponent/ListComponent.razor index 0a3738a..fa20d1a 100644 --- a/WatchIt.Website/WatchIt.Website/Components/Pages/DatabasePage/DatabasePageComponent.razor +++ b/WatchIt.Website/WatchIt.Website/Components/Common/ListComponent/ListComponent.razor @@ -60,6 +60,8 @@ PosterPlaceholder="@(PosterPlaceholder)" PosterDownloadingTask="@(action => PictureDownloadingTask(id, action))" GlobalRating="@(RatingSource(item))" + SecondaryRating="@(SecondaryRatingSource?.Invoke(item))" + SecondaryRatingTitle="@(SecondaryRatingTitle)" GetGlobalRatingMethod="@(action => GetGlobalRatingMethod(id, action))" GetUserRatingMethod="@(GetUserRatingMethod is not null ? (user, actionSuccess, actionNotFound) => GetUserRatingMethod(id, user, actionSuccess, actionNotFound) : null)" PutRatingMethod="@(PutRatingMethod is not null ? (request) => PutRatingMethod(id, request) : null)" diff --git a/WatchIt.Website/WatchIt.Website/Components/Pages/DatabasePage/DatabasePageComponent.razor.cs b/WatchIt.Website/WatchIt.Website/Components/Common/ListComponent/ListComponent.razor.cs similarity index 92% rename from WatchIt.Website/WatchIt.Website/Components/Pages/DatabasePage/DatabasePageComponent.razor.cs rename to WatchIt.Website/WatchIt.Website/Components/Common/ListComponent/ListComponent.razor.cs index 85791ad..ce6093d 100644 --- a/WatchIt.Website/WatchIt.Website/Components/Pages/DatabasePage/DatabasePageComponent.razor.cs +++ b/WatchIt.Website/WatchIt.Website/Components/Common/ListComponent/ListComponent.razor.cs @@ -4,9 +4,9 @@ using WatchIt.Common.Model.Movies; using WatchIt.Common.Model.Rating; using WatchIt.Common.Query; -namespace WatchIt.Website.Components.Pages.DatabasePage; +namespace WatchIt.Website.Components.Common.ListComponent; -public partial class DatabasePageComponent : ComponentBase where TItem : IQueryOrderable where TQuery : QueryParameters +public partial class ListComponent : ComponentBase where TItem : IQueryOrderable where TQuery : QueryParameters { #region SERVICES @@ -23,6 +23,8 @@ public partial class DatabasePageComponent : ComponentBase where [Parameter] public required Func NameSource { get; set; } [Parameter] public Func AdditionalNameInfoSource { get; set; } = _ => null; [Parameter] public required Func RatingSource { get; set; } + [Parameter] public Func? SecondaryRatingSource { get; set; } + [Parameter] public string? SecondaryRatingTitle { get; set; } [Parameter] public required string UrlIdTemplate { get; set; } [Parameter] public required Func, Task> PictureDownloadingTask { get; set; } [Parameter] public required Func>, Task> ItemDownloadingTask { get; set; } diff --git a/WatchIt.Website/WatchIt.Website/Components/Common/Subcomponents/DisplayRatingComponent.razor b/WatchIt.Website/WatchIt.Website/Components/Common/Subcomponents/DisplayRatingComponent.razor index da7a6c5..47a14b9 100644 --- a/WatchIt.Website/WatchIt.Website/Components/Common/Subcomponents/DisplayRatingComponent.razor +++ b/WatchIt.Website/WatchIt.Website/Components/Common/Subcomponents/DisplayRatingComponent.razor @@ -5,14 +5,18 @@ }
- @if (Rating is not null && Rating.Count > 0) + @if (SingleRating is not null) + { + @($"{SingleRating}/10") + } + else if (Rating is not null && Rating.Count > 0) { @($"{Math.Round(Rating.Average, 2)}/10") @(Rating.Count) } else { -
+
@if (Rating is null) {
/10
@@ -40,7 +44,7 @@ font-size: @((1.3 * Scale).ToCultureInvariantString())rem; } - #ratingNoItems { + #ratingSingleLine { font-size: @((1.3 * Scale).ToCultureInvariantString())rem; } diff --git a/WatchIt.Website/WatchIt.Website/Components/Common/Subcomponents/DisplayRatingComponent.razor.cs b/WatchIt.Website/WatchIt.Website/Components/Common/Subcomponents/DisplayRatingComponent.razor.cs index 8f6935e..8c8be62 100644 --- a/WatchIt.Website/WatchIt.Website/Components/Common/Subcomponents/DisplayRatingComponent.razor.cs +++ b/WatchIt.Website/WatchIt.Website/Components/Common/Subcomponents/DisplayRatingComponent.razor.cs @@ -8,6 +8,7 @@ public partial class DisplayRatingComponent : ComponentBase #region PARAMETERS [Parameter] public RatingResponse? Rating { get; set; } + [Parameter] public short? SingleRating { get; set; } [Parameter] public DisplayRatingComponentEmptyMode EmptyMode { get; set; } = DisplayRatingComponentEmptyMode.NoRatings; [Parameter] public double Scale { get; set; } = 1; diff --git a/WatchIt.Website/WatchIt.Website/Components/Common/Subcomponents/ListItemComponent.razor b/WatchIt.Website/WatchIt.Website/Components/Common/Subcomponents/ListItemComponent.razor index 42b9837..b87ecbd 100644 --- a/WatchIt.Website/WatchIt.Website/Components/Common/Subcomponents/ListItemComponent.razor +++ b/WatchIt.Website/WatchIt.Website/Components/Common/Subcomponents/ListItemComponent.razor @@ -12,40 +12,66 @@ @(Name)@(string.IsNullOrWhiteSpace(AdditionalInfo) ? string.Empty : AdditionalInfo)
-
- -
- Global rating: - -
-
- @if (GetUserRatingMethod is not null && PutRatingMethod is not null && DeleteRatingMethod is not null) - { -
-
- Your rating: -
- @if (_user is null) - { - You must be logged in to rate - } - else if (!_userRatingLoaded) - { -
- - Loading... + + + + + @if (SecondaryRating is not null) + { + + } + @if (GetUserRatingMethod is not null && PutRatingMethod is not null && DeleteRatingMethod is not null) + { + + } + + + + + + @if (SecondaryRating is not null) + { + + } + @if (GetUserRatingMethod is not null && PutRatingMethod is not null && DeleteRatingMethod is not null) + { + + } + + +
+ Global rating: + + @(SecondaryRatingTitle): + + Your rating: +
+ + + + +
+ @if (_user is null) + { + You must be logged in to rate + } + else if (!_userRatingLoaded) + { +
+ + Loading... +
+ } + else + { + + }
- } - else - { - - } - - - } - +
diff --git a/WatchIt.Website/WatchIt.Website/Components/Common/Subcomponents/ListItemComponent.razor.cs b/WatchIt.Website/WatchIt.Website/Components/Common/Subcomponents/ListItemComponent.razor.cs index 326dbf1..4189a8e 100644 --- a/WatchIt.Website/WatchIt.Website/Components/Common/Subcomponents/ListItemComponent.razor.cs +++ b/WatchIt.Website/WatchIt.Website/Components/Common/Subcomponents/ListItemComponent.razor.cs @@ -27,6 +27,8 @@ public partial class ListItemComponent : ComponentBase [Parameter] public required Func, Task> PosterDownloadingTask { get; set; } [Parameter] public RatingResponse? GlobalRating { get; set; } + [Parameter] public short? SecondaryRating { get; set; } + [Parameter] public string? SecondaryRatingTitle { get; set; } [Parameter] public required Func, Task> GetGlobalRatingMethod { get; set; } [Parameter] public Func, Action, Task>? GetUserRatingMethod { get; set; } [Parameter] public Func? PutRatingMethod { get; set; } diff --git a/WatchIt.Website/WatchIt.Website/Components/Common/Subcomponents/ListItemComponent.razor.css b/WatchIt.Website/WatchIt.Website/Components/Common/Subcomponents/ListItemComponent.razor.css index 7c26de1..195130b 100644 --- a/WatchIt.Website/WatchIt.Website/Components/Common/Subcomponents/ListItemComponent.razor.css +++ b/WatchIt.Website/WatchIt.Website/Components/Common/Subcomponents/ListItemComponent.razor.css @@ -1,10 +1,39 @@ -/* IDS */ +/* TAGS */ -#ratingNameText { - font-size: 14px; - font-weight: bold; +tbody, td, tfoot, th, thead, tr { + border-color: inherit; + border-style: unset; + border-width: 0; } + + +/* IDS */ + #ratingLoginInfoText { font-size: 13px; +} + +#ratingTable { + width: fit-content; + border-spacing: unset; + border-collapse: separate; + margin-left: -0.5rem !important; +} + +#ratingTable > thead > tr > th:not(:last-child) { + border-right: 1px solid #444; +} + +#ratingTable > tbody > tr > td:not(:last-child) { + border-right: 1px solid #444; +} + + + +/* CLASSES */ + +.rating-name-text { + font-size: 14px; + font-weight: bold; } \ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Components/Pages/DatabasePage/Subcomponents/MoviesFilterFormComponent.razor b/WatchIt.Website/WatchIt.Website/Components/Pages/DatabasePage/Subcomponents/MoviesFilterFormComponent.razor index d24e473..eac3a8d 100644 --- a/WatchIt.Website/WatchIt.Website/Components/Pages/DatabasePage/Subcomponents/MoviesFilterFormComponent.razor +++ b/WatchIt.Website/WatchIt.Website/Components/Pages/DatabasePage/Subcomponents/MoviesFilterFormComponent.razor @@ -1,4 +1,4 @@ -@inherits FilterFormComponent +@inherits WatchIt.Website.Components.Common.ListComponent.FilterFormComponent diff --git a/WatchIt.Website/WatchIt.Website/Components/Pages/DatabasePage/Subcomponents/PersonsFilterFormComponent.razor b/WatchIt.Website/WatchIt.Website/Components/Pages/DatabasePage/Subcomponents/PersonsFilterFormComponent.razor index 7f251bf..1979f14 100644 --- a/WatchIt.Website/WatchIt.Website/Components/Pages/DatabasePage/Subcomponents/PersonsFilterFormComponent.razor +++ b/WatchIt.Website/WatchIt.Website/Components/Pages/DatabasePage/Subcomponents/PersonsFilterFormComponent.razor @@ -1,5 +1,5 @@ @using WatchIt.Common.Model.Genders -@inherits FilterFormComponent +@inherits WatchIt.Website.Components.Common.ListComponent.FilterFormComponent diff --git a/WatchIt.Website/WatchIt.Website/Components/Pages/DatabasePage/Subcomponents/PersonsFilterFormComponent.razor.cs b/WatchIt.Website/WatchIt.Website/Components/Pages/DatabasePage/Subcomponents/PersonsFilterFormComponent.razor.cs index c57a68a..778fb2d 100644 --- a/WatchIt.Website/WatchIt.Website/Components/Pages/DatabasePage/Subcomponents/PersonsFilterFormComponent.razor.cs +++ b/WatchIt.Website/WatchIt.Website/Components/Pages/DatabasePage/Subcomponents/PersonsFilterFormComponent.razor.cs @@ -1,6 +1,7 @@ using Microsoft.AspNetCore.Components; using WatchIt.Common.Model.Genders; using WatchIt.Common.Model.Persons; +using WatchIt.Website.Components.Common.ListComponent; using WatchIt.Website.Services.Client.Genders; namespace WatchIt.Website.Components.Pages.DatabasePage.Subcomponents; diff --git a/WatchIt.Website/WatchIt.Website/Components/Pages/DatabasePage/Subcomponents/SeriesFilterFormComponent.razor b/WatchIt.Website/WatchIt.Website/Components/Pages/DatabasePage/Subcomponents/SeriesFilterFormComponent.razor index 1bad8cc..141a655 100644 --- a/WatchIt.Website/WatchIt.Website/Components/Pages/DatabasePage/Subcomponents/SeriesFilterFormComponent.razor +++ b/WatchIt.Website/WatchIt.Website/Components/Pages/DatabasePage/Subcomponents/SeriesFilterFormComponent.razor @@ -1,4 +1,4 @@ -@inherits FilterFormComponent +@inherits WatchIt.Website.Components.Common.ListComponent.FilterFormComponent
diff --git a/WatchIt.Website/WatchIt.Website/Components/Pages/UserPage/Subcomponents/MoviesRatedFilterFormComponent.razor b/WatchIt.Website/WatchIt.Website/Components/Pages/UserPage/Subcomponents/MoviesRatedFilterFormComponent.razor new file mode 100644 index 0000000..5712d5b --- /dev/null +++ b/WatchIt.Website/WatchIt.Website/Components/Pages/UserPage/Subcomponents/MoviesRatedFilterFormComponent.razor @@ -0,0 +1,74 @@ +@inherits WatchIt.Website.Components.Common.ListComponent.FilterFormComponent + + + + +
+
+
+ Title + +
+
+
+
+ Original title + +
+
+
+
+ Description + +
+
+
+
+ Release date + + - + +
+
+
+
+ Length + + - + +
+
+
+
+ Budget + + - + +
+
+
+
+ Rating (count) + + - + +
+
+
+
+ Rating (average) + + - + +
+
+
+
+ User rating + + - + +
+
+
+
\ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Components/Pages/UserPage/Subcomponents/SeriesRatedFilterFormComponent.razor b/WatchIt.Website/WatchIt.Website/Components/Pages/UserPage/Subcomponents/SeriesRatedFilterFormComponent.razor new file mode 100644 index 0000000..7c23456 --- /dev/null +++ b/WatchIt.Website/WatchIt.Website/Components/Pages/UserPage/Subcomponents/SeriesRatedFilterFormComponent.razor @@ -0,0 +1,77 @@ +@inherits WatchIt.Website.Components.Common.ListComponent.FilterFormComponent + + +
+
+
+ Title + +
+
+
+
+ Original title + +
+
+
+
+ Description + +
+
+
+
+ Release date + + - + +
+
+
+
+ Length + + - + +
+
+
+
+ Has ended +
+ + + + + + +
+
+
+
+
+ Rating (count) + + - + +
+
+
+
+ Rating (average) + + - + +
+
+
+
+ User rating + + - + +
+
+
+
\ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Layout/MainLayout.razor b/WatchIt.Website/WatchIt.Website/Layout/MainLayout.razor index ac67a74..5d34a04 100644 --- a/WatchIt.Website/WatchIt.Website/Layout/MainLayout.razor +++ b/WatchIt.Website/WatchIt.Website/Layout/MainLayout.razor @@ -79,7 +79,7 @@
-
+
@Body
diff --git a/WatchIt.Website/WatchIt.Website/Pages/DatabasePage.razor b/WatchIt.Website/WatchIt.Website/Pages/DatabasePage.razor index c1cbd6a..c5e6630 100644 --- a/WatchIt.Website/WatchIt.Website/Pages/DatabasePage.razor +++ b/WatchIt.Website/WatchIt.Website/Pages/DatabasePage.razor @@ -3,6 +3,7 @@ @using WatchIt.Common.Model.Series @using WatchIt.Website.Components.Pages.DatabasePage @using WatchIt.Website.Components.Pages.DatabasePage.Subcomponents +@using WatchIt.Website.Components.Common.ListComponent @page "/database/{type?}" @@ -30,78 +31,78 @@ @switch (Type) { case "movies": - + - + break; case "series": - + - + break; case "people": - + - + break; } \ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Pages/UserPage.razor b/WatchIt.Website/WatchIt.Website/Pages/UserPage.razor index 430ada9..cc72a42 100644 --- a/WatchIt.Website/WatchIt.Website/Pages/UserPage.razor +++ b/WatchIt.Website/WatchIt.Website/Pages/UserPage.razor @@ -1,5 +1,9 @@ @using System.Text +@using WatchIt.Common.Model.Movies +@using WatchIt.Common.Model.Series @using WatchIt.Website.Components.Pages.UserPage.Panels +@using WatchIt.Website.Components.Common.ListComponent +@using WatchIt.Website.Components.Pages.UserPage.Subcomponents @page "/user/{id:long?}" @@ -56,17 +60,59 @@ Movies TV Series People - Roles + Roles - +
+ + + +
- +
+ + + +
diff --git a/WatchIt.Website/WatchIt.Website/Pages/UserPage.razor.cs b/WatchIt.Website/WatchIt.Website/Pages/UserPage.razor.cs index 7685fa6..7a190ff 100644 --- a/WatchIt.Website/WatchIt.Website/Pages/UserPage.razor.cs +++ b/WatchIt.Website/WatchIt.Website/Pages/UserPage.razor.cs @@ -3,6 +3,7 @@ using WatchIt.Common.Model.Accounts; using WatchIt.Website.Layout; using WatchIt.Website.Services.Authentication; using WatchIt.Website.Services.Client.Accounts; +using WatchIt.Website.Services.Client.Media; namespace WatchIt.Website.Pages; @@ -13,6 +14,7 @@ public partial class UserPage : ComponentBase [Inject] private NavigationManager NavigationManager { get; set; } = default!; [Inject] private IAuthenticationService AuthenticationService { get; set; } = default!; [Inject] private IAccountsClientService AccountsClientService { get; set; } = default!; + [Inject] private IMediaClientService MediaClientService { get; set; } = default!; #endregion @@ -78,7 +80,7 @@ public partial class UserPage : ComponentBase Id = user.Id; } - await AccountsClientService.GetAccountInfoById(Id.Value, data => _accountData = data); + await AccountsClientService.GetAccountInfo(Id.Value, data => _accountData = data); _owner = Id.Value == user?.Id; } diff --git a/WatchIt.Website/WatchIt.Website/appsettings.json b/WatchIt.Website/WatchIt.Website/appsettings.json index 3613545..9116ddb 100644 --- a/WatchIt.Website/WatchIt.Website/appsettings.json +++ b/WatchIt.Website/WatchIt.Website/appsettings.json @@ -22,9 +22,10 @@ "AuthenticateRefresh": "/authenticate-refresh", "Logout": "/logout", "GetProfilePicture": "/{0}/profile-picture", - "GetAccountInfoById": "/{0}/info", - "GetAccountInfo": "/info", - "PutAccountInfo": "/info" + "GetAccountInfo": "/{0}/info", + "PutAccountInfo": "/info", + "GetAccountRatedMovies": "/{0}/movies", + "GetAccountRatedSeries": "/{0}/series" }, "Genders": { "Base": "/genders",