diff --git a/.github/config/gitversion.yml b/.github/config/gitversion.yml index d7a5142..500e0b6 100644 --- a/.github/config/gitversion.yml +++ b/.github/config/gitversion.yml @@ -1,4 +1,4 @@ -next-version: 0.2.0 +next-version: 0.3.0 assembly-versioning-scheme: MajorMinorPatch assembly-file-versioning-scheme: MajorMinorPatch diff --git a/WatchIt.Common/WatchIt.Common.Model/Genders/Gender.cs b/WatchIt.Common/WatchIt.Common.Model/Genders/Gender.cs new file mode 100644 index 0000000..9cb7c2e --- /dev/null +++ b/WatchIt.Common/WatchIt.Common.Model/Genders/Gender.cs @@ -0,0 +1,13 @@ +using System.Text.Json.Serialization; + +namespace WatchIt.Common.Model.Genders; + +public class Gender +{ + #region PROPERTIES + + [JsonPropertyName("name")] + public required string Name { get; set; } + + #endregion +} \ No newline at end of file diff --git a/WatchIt.Common/WatchIt.Common.Model/Genders/GenderQueryParameters.cs b/WatchIt.Common/WatchIt.Common.Model/Genders/GenderQueryParameters.cs new file mode 100644 index 0000000..490a674 --- /dev/null +++ b/WatchIt.Common/WatchIt.Common.Model/Genders/GenderQueryParameters.cs @@ -0,0 +1,22 @@ +using Microsoft.AspNetCore.Mvc; +using WatchIt.Common.Query; + +namespace WatchIt.Common.Model.Genders; + +public class GenderQueryParameters : QueryParameters +{ + #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 +} \ No newline at end of file diff --git a/WatchIt.Common/WatchIt.Common.Model/Genders/GenderRequest.cs b/WatchIt.Common/WatchIt.Common.Model/Genders/GenderRequest.cs new file mode 100644 index 0000000..60f5a42 --- /dev/null +++ b/WatchIt.Common/WatchIt.Common.Model/Genders/GenderRequest.cs @@ -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 +} \ No newline at end of file diff --git a/WatchIt.Common/WatchIt.Common.Model/Genders/GenderResponse.cs b/WatchIt.Common/WatchIt.Common.Model/Genders/GenderResponse.cs new file mode 100644 index 0000000..16eeeec --- /dev/null +++ b/WatchIt.Common/WatchIt.Common.Model/Genders/GenderResponse.cs @@ -0,0 +1,38 @@ +using System.Diagnostics.CodeAnalysis; +using System.Text.Json.Serialization; +using WatchIt.Common.Query; + +namespace WatchIt.Common.Model.Genders; + +public class GenderResponse : Gender, IQueryOrderable +{ + #region PROPERTIES + + [JsonIgnore] + public static IDictionary> OrderableProperties { get; } = new Dictionary> + { + { "name", item => item.Name } + }; + + + [JsonPropertyName("id")] + public required short? Id { get; set; } + + #endregion + + + + #region CONSTRUCTORS + + [JsonConstructor] + public GenderResponse() { } + + [SetsRequiredMembers] + public GenderResponse(Database.Model.Common.Gender gender) + { + Id = gender.Id; + Name = gender.Name; + } + + #endregion +} \ No newline at end of file diff --git a/WatchIt.Common/WatchIt.Common.Model/Genres/GenreQueryParameters.cs b/WatchIt.Common/WatchIt.Common.Model/Genres/GenreQueryParameters.cs index 9b2658c..220b5e4 100644 --- a/WatchIt.Common/WatchIt.Common.Model/Genres/GenreQueryParameters.cs +++ b/WatchIt.Common/WatchIt.Common.Model/Genres/GenreQueryParameters.cs @@ -17,9 +17,9 @@ public class GenreQueryParameters : QueryParameters - #region PUBLIC METHODS + #region PRIVATE METHODS - public override bool IsMeetingConditions(GenreResponse item) => + protected override bool IsMeetingConditions(GenreResponse item) => ( TestStringWithRegex(item.Name, Name) && diff --git a/WatchIt.Common/WatchIt.Common.Model/Media/MediaPosterRequest.cs b/WatchIt.Common/WatchIt.Common.Model/Media/MediaPosterRequest.cs index 5a9fa95..1b83f1a 100644 --- a/WatchIt.Common/WatchIt.Common.Model/Media/MediaPosterRequest.cs +++ b/WatchIt.Common/WatchIt.Common.Model/Media/MediaPosterRequest.cs @@ -10,10 +10,10 @@ public class MediaPosterRequest : MediaPoster public MediaPosterRequest() {} [SetsRequiredMembers] - public MediaPosterRequest(MediaPosterResponse response) + public MediaPosterRequest(Picture image) { - Image = response.Image; - MimeType = response.MimeType; + Image = image.Image; + MimeType = image.MimeType; } #endregion diff --git a/WatchIt.Common/WatchIt.Common.Model/Media/MediaQueryParameters.cs b/WatchIt.Common/WatchIt.Common.Model/Media/MediaQueryParameters.cs index 3977d12..fcbfe10 100644 --- a/WatchIt.Common/WatchIt.Common.Model/Media/MediaQueryParameters.cs +++ b/WatchIt.Common/WatchIt.Common.Model/Media/MediaQueryParameters.cs @@ -59,9 +59,9 @@ public class MediaQueryParameters : QueryParameters - #region PUBLIC METHODS + #region PRIVATE METHODS - public override bool IsMeetingConditions(MediaResponse item) => + protected override bool IsMeetingConditions(MediaResponse item) => ( Test(item.Type, Type) && diff --git a/WatchIt.Common/WatchIt.Common.Model/Media/MediaResponse.cs b/WatchIt.Common/WatchIt.Common.Model/Media/MediaResponse.cs index 4ee0ba9..fd10ae8 100644 --- a/WatchIt.Common/WatchIt.Common.Model/Media/MediaResponse.cs +++ b/WatchIt.Common/WatchIt.Common.Model/Media/MediaResponse.cs @@ -51,7 +51,7 @@ public class MediaResponse : Media, IQueryOrderable ReleaseDate = media.ReleaseDate; Length = media.Length; Type = mediaType; - Rating = new RatingResponse(media.RatingMedia); + Rating = RatingResponse.Create(media.RatingMedia); } #endregion diff --git a/WatchIt.Common/WatchIt.Common.Model/Movies/MovieQueryParameters.cs b/WatchIt.Common/WatchIt.Common.Model/Movies/MovieQueryParameters.cs index aec1df9..ede62e0 100644 --- a/WatchIt.Common/WatchIt.Common.Model/Movies/MovieQueryParameters.cs +++ b/WatchIt.Common/WatchIt.Common.Model/Movies/MovieQueryParameters.cs @@ -65,9 +65,9 @@ public class MovieQueryParameters : QueryParameters - #region PUBLIC METHODS + #region PRIVATE METHODS - public override bool IsMeetingConditions(MovieResponse item) => + protected override bool IsMeetingConditions(MovieResponse item) => ( TestStringWithRegex(item.Title, Title) && diff --git a/WatchIt.Common/WatchIt.Common.Model/Movies/MovieResponse.cs b/WatchIt.Common/WatchIt.Common.Model/Movies/MovieResponse.cs index 78a230c..366b058 100644 --- a/WatchIt.Common/WatchIt.Common.Model/Movies/MovieResponse.cs +++ b/WatchIt.Common/WatchIt.Common.Model/Movies/MovieResponse.cs @@ -50,7 +50,7 @@ public class MovieResponse : Movie, IQueryOrderable ReleaseDate = mediaMovie.Media.ReleaseDate; Length = mediaMovie.Media.Length; Budget = mediaMovie.Budget; - Rating = new RatingResponse(mediaMovie.Media.RatingMedia); + Rating = RatingResponse.Create(mediaMovie.Media.RatingMedia); } #endregion diff --git a/WatchIt.Common/WatchIt.Common.Model/Persons/Person.cs b/WatchIt.Common/WatchIt.Common.Model/Persons/Person.cs new file mode 100644 index 0000000..0980294 --- /dev/null +++ b/WatchIt.Common/WatchIt.Common.Model/Persons/Person.cs @@ -0,0 +1,25 @@ +using System.Text.Json.Serialization; + +namespace WatchIt.Common.Model.Persons; + +public class Person +{ + #region PROPERTIES + + [JsonPropertyName("name")] + public required string Name { get; set; } + + [JsonPropertyName("full_name")] + public string? FullName { get; set; } + + [JsonPropertyName("description")] + public string? Description { get; set; } + + [JsonPropertyName("birth_date")] + public DateOnly? BirthDate { get; set; } + + [JsonPropertyName("death_date")] + public DateOnly? DeathDate { get; set; } + + #endregion +} \ No newline at end of file diff --git a/WatchIt.Common/WatchIt.Common.Model/Persons/PersonPhoto.cs b/WatchIt.Common/WatchIt.Common.Model/Persons/PersonPhoto.cs new file mode 100644 index 0000000..67094f6 --- /dev/null +++ b/WatchIt.Common/WatchIt.Common.Model/Persons/PersonPhoto.cs @@ -0,0 +1,6 @@ +namespace WatchIt.Common.Model.Persons; + +public class PersonPhoto : Picture +{ + +} \ No newline at end of file diff --git a/WatchIt.Common/WatchIt.Common.Model/Persons/PersonPhotoRequest.cs b/WatchIt.Common/WatchIt.Common.Model/Persons/PersonPhotoRequest.cs new file mode 100644 index 0000000..8397887 --- /dev/null +++ b/WatchIt.Common/WatchIt.Common.Model/Persons/PersonPhotoRequest.cs @@ -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 +} \ No newline at end of file diff --git a/WatchIt.Common/WatchIt.Common.Model/Persons/PersonPhotoResponse.cs b/WatchIt.Common/WatchIt.Common.Model/Persons/PersonPhotoResponse.cs new file mode 100644 index 0000000..957e76c --- /dev/null +++ b/WatchIt.Common/WatchIt.Common.Model/Persons/PersonPhotoResponse.cs @@ -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 +} \ No newline at end of file diff --git a/WatchIt.Common/WatchIt.Common.Model/Persons/PersonQueryParameters.cs b/WatchIt.Common/WatchIt.Common.Model/Persons/PersonQueryParameters.cs new file mode 100644 index 0000000..0cd03ed --- /dev/null +++ b/WatchIt.Common/WatchIt.Common.Model/Persons/PersonQueryParameters.cs @@ -0,0 +1,84 @@ +using Microsoft.AspNetCore.Mvc; +using WatchIt.Common.Query; + +namespace WatchIt.Common.Model.Persons; + +public class PersonQueryParameters : QueryParameters +{ + #region PROPERTIES + + [FromQuery(Name = "name")] + public string? Name { get; set; } + + [FromQuery(Name = "full_name")] + public string? FullName { get; set; } + + [FromQuery(Name = "description")] + public string? Description { get; set; } + + [FromQuery(Name = "birth_date")] + public DateOnly? BirthDate { get; set; } + + [FromQuery(Name = "birth_date_from")] + public DateOnly? BirthDateFrom { get; set; } + + [FromQuery(Name = "birth_date_to")] + public DateOnly? BirthDateTo { get; set; } + + [FromQuery(Name = "death_date")] + public DateOnly? DeathDate { get; set; } + + [FromQuery(Name = "death_date_from")] + public DateOnly? DeathDateFrom { get; set; } + + [FromQuery(Name = "death_date_to")] + public DateOnly? DeathDateTo { get; set; } + + [FromQuery(Name = "gender_id")] + public short? GenderId { 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; } + + #endregion + + + + #region PUBLIC METHODS + + protected override bool IsMeetingConditions(PersonResponse item) => + ( + TestStringWithRegex(item.Name, Name) + && + TestStringWithRegex(item.FullName, FullName) + && + TestStringWithRegex(item.Description, Description) + && + TestComparable(item.BirthDate, BirthDate, BirthDateFrom, BirthDateTo) + && + TestComparable(item.DeathDate, DeathDate, DeathDateFrom, DeathDateTo) + && + Test(item.Gender?.Id, GenderId) + && + TestComparable(item.Rating.Average, RatingAverage, RatingAverageFrom, RatingAverageTo) + && + TestComparable(item.Rating.Count, RatingCount, RatingCountFrom, RatingCountTo) + ); + + #endregion +} \ No newline at end of file diff --git a/WatchIt.Common/WatchIt.Common.Model/Persons/PersonRequest.cs b/WatchIt.Common/WatchIt.Common.Model/Persons/PersonRequest.cs new file mode 100644 index 0000000..7e7052b --- /dev/null +++ b/WatchIt.Common/WatchIt.Common.Model/Persons/PersonRequest.cs @@ -0,0 +1,63 @@ +using System.Diagnostics.CodeAnalysis; +using System.Text.Json.Serialization; + +namespace WatchIt.Common.Model.Persons; + +public class PersonRequest : Person +{ + #region PROPERTIES + + [JsonPropertyName("gender_id")] + public short? GenderId { get; set; } + + #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 + + + + #region PUBLIC METHODS + + public Database.Model.Person.Person CreatePerson() => new Database.Model.Person.Person + { + Name = Name, + FullName = FullName, + Description = Description, + BirthDate = BirthDate, + DeathDate = DeathDate, + GenderId = GenderId, + }; + + public void UpdatePerson(Database.Model.Person.Person person) + { + person.Name = Name; + person.FullName = FullName; + person.Description = Description; + person.BirthDate = BirthDate; + person.DeathDate = DeathDate; + person.GenderId = GenderId; + } + + #endregion +} \ No newline at end of file diff --git a/WatchIt.Common/WatchIt.Common.Model/Persons/PersonResponse.cs b/WatchIt.Common/WatchIt.Common.Model/Persons/PersonResponse.cs new file mode 100644 index 0000000..a81e5ab --- /dev/null +++ b/WatchIt.Common/WatchIt.Common.Model/Persons/PersonResponse.cs @@ -0,0 +1,60 @@ +using System.Diagnostics.CodeAnalysis; +using System.Text.Json.Serialization; +using WatchIt.Common.Model.Genders; +using WatchIt.Common.Model.Rating; +using WatchIt.Common.Query; + +namespace WatchIt.Common.Model.Persons; + +public class PersonResponse : Person, IQueryOrderable +{ + #region PROPERTIES + + [JsonIgnore] + public static IDictionary> OrderableProperties { get; } = new Dictionary> + { + { "id", x => x.Id }, + { "name", x => x.Name }, + { "full_name", x => x.FullName }, + { "description", x => x.Description }, + { "birth_date", x => x.BirthDate }, + { "death_date", x => x.BirthDate }, + { "gender", x => x.Gender.Name }, + { "rating.average", x => x.Rating.Average }, + { "rating.count", x => x.Rating.Count } + }; + + + [JsonPropertyName("id")] + public required long Id { get; set; } + + [JsonPropertyName("gender")] + public GenderResponse? Gender { get; set; } + + [JsonPropertyName("rating")] + public required RatingResponse Rating { get; set; } + + #endregion + + + + #region CONSTRUCTORS + + [JsonConstructor] + public PersonResponse() { } + + [SetsRequiredMembers] + public PersonResponse(Database.Model.Person.Person person) + { + Id = person.Id; + Name = person.Name; + FullName = person.FullName; + Description = person.Description; + BirthDate = person.BirthDate; + DeathDate = person.DeathDate; + Gender = person.Gender is not null ? new GenderResponse(person.Gender) : null; + Rating = RatingResponse.Create(person.PersonActorRoles, person.PersonCreatorRoles); + } + + #endregion +} \ No newline at end of file diff --git a/WatchIt.Common/WatchIt.Common.Model/Photos/PhotoQueryParameters.cs b/WatchIt.Common/WatchIt.Common.Model/Photos/PhotoQueryParameters.cs index b9d2794..33b5610 100644 --- a/WatchIt.Common/WatchIt.Common.Model/Photos/PhotoQueryParameters.cs +++ b/WatchIt.Common/WatchIt.Common.Model/Photos/PhotoQueryParameters.cs @@ -32,9 +32,9 @@ public class PhotoQueryParameters : QueryParameters - #region PUBLIC METHODS + #region PRIVATE METHODS - public override bool IsMeetingConditions(PhotoResponse item) => + protected override bool IsMeetingConditions(PhotoResponse item) => ( TestStringWithRegex(item.MimeType, MimeType) && diff --git a/WatchIt.Common/WatchIt.Common.Model/Picture.cs b/WatchIt.Common/WatchIt.Common.Model/Picture.cs index ab0e8ee..b16065e 100644 --- a/WatchIt.Common/WatchIt.Common.Model/Picture.cs +++ b/WatchIt.Common/WatchIt.Common.Model/Picture.cs @@ -2,7 +2,7 @@ using System.Text.Json.Serialization; namespace WatchIt.Common.Model; -public abstract class Picture +public class Picture { #region PROPERTIES diff --git a/WatchIt.Common/WatchIt.Common.Model/Rating/RatingResponse.cs b/WatchIt.Common/WatchIt.Common.Model/Rating/RatingResponse.cs index cc86fb2..9037814 100644 --- a/WatchIt.Common/WatchIt.Common.Model/Rating/RatingResponse.cs +++ b/WatchIt.Common/WatchIt.Common.Model/Rating/RatingResponse.cs @@ -1,5 +1,6 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json.Serialization; +using WatchIt.Database.Model.Person; using WatchIt.Database.Model.Rating; namespace WatchIt.Common.Model.Rating; @@ -24,14 +25,35 @@ public class RatingResponse public RatingResponse() {} [SetsRequiredMembers] - public RatingResponse(IEnumerable ratingMedia) : this(ratingMedia.Any() ? (decimal)ratingMedia.Average(x => x.Rating) : 0, ratingMedia.Count()) {} - - [SetsRequiredMembers] - public RatingResponse(decimal ratingAverage, long ratingCount) + private RatingResponse(long ratingSum, long ratingCount) { - Average = ratingAverage; + Average = ratingCount > 0 ? (decimal)ratingSum / ratingCount : 0; Count = ratingCount; } + public static RatingResponse Create(long ratingSum, long ratingCount) => new RatingResponse(ratingSum, ratingCount); + + public static RatingResponse Create(IEnumerable ratingMedia) => Create(ratingMedia, x => x.Rating); + + public static RatingResponse Create(IEnumerable ratingPersonActorRoles) => Create(ratingPersonActorRoles, x => x.Rating); + + public static RatingResponse Create(IEnumerable ratingPersonCreatorRoles) => Create(ratingPersonCreatorRoles, x => x.Rating); + + public static RatingResponse Create(IEnumerable ratingList, Func ratingSelector) => new RatingResponse(ratingList.Sum(x => ratingSelector(x)), ratingList.Count()); + + public static RatingResponse Create(IEnumerable personActorRoles, IEnumerable personCreatorRoles) + { + IEnumerable ratingsActorRoles = personActorRoles.SelectMany(x => x.RatingPersonActorRole); + IEnumerable ratingsCreatorRoles = personCreatorRoles.SelectMany(x => x.RatingPersonCreatorRole); + return Create(ratingsActorRoles, ratingsCreatorRoles); + } + + public static RatingResponse Create(IEnumerable ratingsActorRoles, IEnumerable ratingsCreatorRoles) + { + long ratingSum = ratingsActorRoles.Sum(x => x.Rating) + ratingsCreatorRoles.Sum(x => x.Rating); + long ratingCount = ratingsActorRoles.Count() + ratingsCreatorRoles.Count(); + return new RatingResponse(ratingSum, ratingCount); + } + #endregion } \ No newline at end of file diff --git a/WatchIt.Common/WatchIt.Common.Model/Roles/ActorRole.cs b/WatchIt.Common/WatchIt.Common.Model/Roles/ActorRole.cs new file mode 100644 index 0000000..572748f --- /dev/null +++ b/WatchIt.Common/WatchIt.Common.Model/Roles/ActorRole.cs @@ -0,0 +1,16 @@ +using System.Text.Json.Serialization; + +namespace WatchIt.Common.Model.Roles; + +public abstract class ActorRole +{ + #region PROPERTIES + + [JsonPropertyName("type_id")] + public short TypeId { get; set; } + + [JsonPropertyName("name")] + public string Name { get; set; } + + #endregion +} \ No newline at end of file diff --git a/WatchIt.Common/WatchIt.Common.Model/Roles/ActorRoleMediaQueryParameters.cs b/WatchIt.Common/WatchIt.Common.Model/Roles/ActorRoleMediaQueryParameters.cs new file mode 100644 index 0000000..aea4560 --- /dev/null +++ b/WatchIt.Common/WatchIt.Common.Model/Roles/ActorRoleMediaQueryParameters.cs @@ -0,0 +1,26 @@ +using Microsoft.AspNetCore.Mvc; + +namespace WatchIt.Common.Model.Roles; + +public class ActorRoleMediaQueryParameters : ActorRoleQueryParameters +{ + #region PROPERTIES + + [FromQuery(Name = "person_id")] + public long? PersonId { get; set; } + + #endregion + + + + #region PRIVATE METHODS + + protected override bool IsMeetingConditions(ActorRoleResponse item) => + ( + base.IsMeetingConditions(item) + && + Test(item.PersonId, PersonId) + ); + + #endregion +} \ No newline at end of file diff --git a/WatchIt.Common/WatchIt.Common.Model/Roles/ActorRoleMediaRequest.cs b/WatchIt.Common/WatchIt.Common.Model/Roles/ActorRoleMediaRequest.cs new file mode 100644 index 0000000..66787b5 --- /dev/null +++ b/WatchIt.Common/WatchIt.Common.Model/Roles/ActorRoleMediaRequest.cs @@ -0,0 +1,22 @@ +using System.Text.Json.Serialization; +using WatchIt.Database.Model.Person; + +namespace WatchIt.Common.Model.Roles; + +public class ActorRoleMediaRequest : ActorRoleRequest, IActorRoleMediaRequest +{ + #region PROPERTIES + + [JsonPropertyName("person_id")] + public long PersonId { get; set; } + + #endregion + + + + #region PUBLIC METHODS + + public PersonActorRole CreateActorRole(long mediaId) => base.CreateActorRole(mediaId, PersonId); + + #endregion +} \ No newline at end of file diff --git a/WatchIt.Common/WatchIt.Common.Model/Roles/ActorRolePersonQueryParameters.cs b/WatchIt.Common/WatchIt.Common.Model/Roles/ActorRolePersonQueryParameters.cs new file mode 100644 index 0000000..b31e24f --- /dev/null +++ b/WatchIt.Common/WatchIt.Common.Model/Roles/ActorRolePersonQueryParameters.cs @@ -0,0 +1,26 @@ +using Microsoft.AspNetCore.Mvc; + +namespace WatchIt.Common.Model.Roles; + +public class ActorRolePersonQueryParameters : ActorRoleQueryParameters +{ + #region PROPERTIES + + [FromQuery(Name = "media_id")] + public long? MediaId { get; set; } + + #endregion + + + + #region PRIVATE METHODS + + protected override bool IsMeetingConditions(ActorRoleResponse item) => + ( + base.IsMeetingConditions(item) + && + Test(item.MediaId, MediaId) + ); + + #endregion +} \ No newline at end of file diff --git a/WatchIt.Common/WatchIt.Common.Model/Roles/ActorRolePersonRequest.cs b/WatchIt.Common/WatchIt.Common.Model/Roles/ActorRolePersonRequest.cs new file mode 100644 index 0000000..aba7c47 --- /dev/null +++ b/WatchIt.Common/WatchIt.Common.Model/Roles/ActorRolePersonRequest.cs @@ -0,0 +1,22 @@ +using System.Text.Json.Serialization; +using WatchIt.Database.Model.Person; + +namespace WatchIt.Common.Model.Roles; + +public class ActorRolePersonRequest : ActorRoleRequest, IActorRolePersonRequest +{ + #region PROPERTIES + + [JsonPropertyName("media_id")] + public long MediaId { get; set; } + + #endregion + + + + #region PUBLIC METHODS + + public PersonActorRole CreateActorRole(long personId) => base.CreateActorRole(MediaId, personId); + + #endregion +} \ No newline at end of file diff --git a/WatchIt.Common/WatchIt.Common.Model/Roles/ActorRoleQueryParameters.cs b/WatchIt.Common/WatchIt.Common.Model/Roles/ActorRoleQueryParameters.cs new file mode 100644 index 0000000..b4a926c --- /dev/null +++ b/WatchIt.Common/WatchIt.Common.Model/Roles/ActorRoleQueryParameters.cs @@ -0,0 +1,32 @@ +using Microsoft.AspNetCore.Mvc; +using WatchIt.Common.Query; + +namespace WatchIt.Common.Model.Roles; + +public abstract class ActorRoleQueryParameters : QueryParameters +{ + #region PROPERTIES + + [FromQuery(Name = "type_id")] + public short? TypeId { get; set; } + + [FromQuery(Name = "name")] + public string? Name { get; set; } + + #endregion + + + + #region PRIVATE METHODS + + protected override bool IsMeetingConditions(ActorRoleResponse item) => + ( + Test(item.TypeId, TypeId) + && + TestStringWithRegex(item.Name, Name) + ); + + #endregion + + +} \ No newline at end of file diff --git a/WatchIt.Common/WatchIt.Common.Model/Roles/ActorRoleRequest.cs b/WatchIt.Common/WatchIt.Common.Model/Roles/ActorRoleRequest.cs new file mode 100644 index 0000000..8b096ad --- /dev/null +++ b/WatchIt.Common/WatchIt.Common.Model/Roles/ActorRoleRequest.cs @@ -0,0 +1,27 @@ +using System.Diagnostics.CodeAnalysis; +using WatchIt.Database.Model.Person; + +namespace WatchIt.Common.Model.Roles; + +public abstract class ActorRoleRequest : ActorRole, IActorRoleRequest +{ + #region PUBLIC METHODS + + public PersonActorRole CreateActorRole(long mediaId, long personId) => new PersonActorRole + { + MediaId = mediaId, + PersonId = personId, + PersonActorRoleTypeId = TypeId, + RoleName = Name, + }; + + public void UpdateActorRole(PersonActorRole item, long mediaId, long personId) + { + item.MediaId = mediaId; + item.PersonId = personId; + item.PersonActorRoleTypeId = TypeId; + item.RoleName = Name; + } + + #endregion +} \ No newline at end of file diff --git a/WatchIt.Common/WatchIt.Common.Model/Roles/ActorRoleResponse.cs b/WatchIt.Common/WatchIt.Common.Model/Roles/ActorRoleResponse.cs new file mode 100644 index 0000000..31d3926 --- /dev/null +++ b/WatchIt.Common/WatchIt.Common.Model/Roles/ActorRoleResponse.cs @@ -0,0 +1,48 @@ +using System.Diagnostics.CodeAnalysis; +using System.Text.Json.Serialization; +using WatchIt.Common.Query; + +namespace WatchIt.Common.Model.Roles; + +public class ActorRoleResponse : ActorRole, IQueryOrderable, IRoleResponse +{ + #region PROPERTIES + + [JsonIgnore] + public static IDictionary> OrderableProperties { get; } = new Dictionary> + { + { "name", item => item.Name }, + { "type_id", item => item.TypeId }, + }; + + + [JsonPropertyName("id")] + public required Guid Id { get; set; } + + [JsonPropertyName("media_id")] + public long MediaId { get; set; } + + [JsonPropertyName("person_id")] + public long PersonId { get; set; } + + #endregion + + + + #region CONSTRUCTORS + + [JsonConstructor] + public ActorRoleResponse() {} + + [SetsRequiredMembers] + public ActorRoleResponse(Database.Model.Person.PersonActorRole data) + { + Id = data.Id; + MediaId = data.MediaId; + PersonId = data.PersonId; + TypeId = data.PersonActorRoleTypeId; + Name = data.RoleName; + } + + #endregion +} \ No newline at end of file diff --git a/WatchIt.Common/WatchIt.Common.Model/Roles/ActorRoleUniversalRequest.cs b/WatchIt.Common/WatchIt.Common.Model/Roles/ActorRoleUniversalRequest.cs new file mode 100644 index 0000000..76ff560 --- /dev/null +++ b/WatchIt.Common/WatchIt.Common.Model/Roles/ActorRoleUniversalRequest.cs @@ -0,0 +1,43 @@ +using System.Text.Json.Serialization; +using WatchIt.Database.Model.Person; + +namespace WatchIt.Common.Model.Roles; + +public class ActorRoleUniversalRequest : ActorRoleRequest, IActorRolePersonRequest, IActorRoleMediaRequest +{ + #region PROPERTIES + + [JsonPropertyName("person_id")] + public long PersonId { get; set; } + + [JsonPropertyName("media_id")] + public long MediaId { get; set; } + + #endregion + + + + #region CONSTRUCTORS + + public ActorRoleUniversalRequest() { } + + public ActorRoleUniversalRequest(ActorRoleResponse data) + { + MediaId = data.MediaId; + PersonId = data.PersonId; + TypeId = data.TypeId; + Name = data.Name; + } + + #endregion + + + + #region PUBLIC METHODS + + public PersonActorRole CreateActorRole() => base.CreateActorRole(MediaId, PersonId); + + public void UpdateActorRole(PersonActorRole item) => base.UpdateActorRole(item, MediaId, PersonId); + + #endregion +} \ No newline at end of file diff --git a/WatchIt.Common/WatchIt.Common.Model/Roles/CreatorRole.cs b/WatchIt.Common/WatchIt.Common.Model/Roles/CreatorRole.cs new file mode 100644 index 0000000..5262eed --- /dev/null +++ b/WatchIt.Common/WatchIt.Common.Model/Roles/CreatorRole.cs @@ -0,0 +1,13 @@ +using System.Text.Json.Serialization; + +namespace WatchIt.Common.Model.Roles; + +public abstract class CreatorRole +{ + #region PROPERTIES + + [JsonPropertyName("type_id")] + public short TypeId { get; set; } + + #endregion +} \ No newline at end of file diff --git a/WatchIt.Common/WatchIt.Common.Model/Roles/CreatorRoleMediaQueryParameters.cs b/WatchIt.Common/WatchIt.Common.Model/Roles/CreatorRoleMediaQueryParameters.cs new file mode 100644 index 0000000..94daf61 --- /dev/null +++ b/WatchIt.Common/WatchIt.Common.Model/Roles/CreatorRoleMediaQueryParameters.cs @@ -0,0 +1,26 @@ +using Microsoft.AspNetCore.Mvc; + +namespace WatchIt.Common.Model.Roles; + +public class CreatorRoleMediaQueryParameters : CreatorRoleQueryParameters +{ + #region PROPERTIES + + [FromQuery(Name = "person_id")] + public long? PersonId { get; set; } + + #endregion + + + + #region PRIVATE METHODS + + protected override bool IsMeetingConditions(CreatorRoleResponse item) => + ( + base.IsMeetingConditions(item) + && + Test(item.PersonId, PersonId) + ); + + #endregion +} \ No newline at end of file diff --git a/WatchIt.Common/WatchIt.Common.Model/Roles/CreatorRoleMediaRequest.cs b/WatchIt.Common/WatchIt.Common.Model/Roles/CreatorRoleMediaRequest.cs new file mode 100644 index 0000000..b256322 --- /dev/null +++ b/WatchIt.Common/WatchIt.Common.Model/Roles/CreatorRoleMediaRequest.cs @@ -0,0 +1,22 @@ +using System.Text.Json.Serialization; +using WatchIt.Database.Model.Person; + +namespace WatchIt.Common.Model.Roles; + +public class CreatorRoleMediaRequest : CreatorRoleRequest, ICreatorRoleMediaRequest +{ + #region PROPERTIES + + [JsonPropertyName("person_id")] + public long PersonId { get; set; } + + #endregion + + + + #region PUBLIC METHODS + + public PersonCreatorRole CreateCreatorRole(long mediaId) => base.CreateCreatorRole(mediaId, PersonId); + + #endregion +} \ No newline at end of file diff --git a/WatchIt.Common/WatchIt.Common.Model/Roles/CreatorRolePersonQueryParameters.cs b/WatchIt.Common/WatchIt.Common.Model/Roles/CreatorRolePersonQueryParameters.cs new file mode 100644 index 0000000..a8604dd --- /dev/null +++ b/WatchIt.Common/WatchIt.Common.Model/Roles/CreatorRolePersonQueryParameters.cs @@ -0,0 +1,26 @@ +using Microsoft.AspNetCore.Mvc; + +namespace WatchIt.Common.Model.Roles; + +public class CreatorRolePersonQueryParameters : CreatorRoleQueryParameters +{ + #region PROPERTIES + + [FromQuery(Name = "media_id")] + public long? MediaId { get; set; } + + #endregion + + + + #region PRIVATE METHODS + + protected override bool IsMeetingConditions(CreatorRoleResponse item) => + ( + base.IsMeetingConditions(item) + && + Test(item.MediaId, MediaId) + ); + + #endregion +} \ No newline at end of file diff --git a/WatchIt.Common/WatchIt.Common.Model/Roles/CreatorRolePersonRequest.cs b/WatchIt.Common/WatchIt.Common.Model/Roles/CreatorRolePersonRequest.cs new file mode 100644 index 0000000..7bf53dd --- /dev/null +++ b/WatchIt.Common/WatchIt.Common.Model/Roles/CreatorRolePersonRequest.cs @@ -0,0 +1,22 @@ +using System.Text.Json.Serialization; +using WatchIt.Database.Model.Person; + +namespace WatchIt.Common.Model.Roles; + +public class CreatorRolePersonRequest : CreatorRoleRequest, ICreatorRolePersonRequest +{ + #region PROPERTIES + + [JsonPropertyName("media_id")] + public long MediaId { get; set; } + + #endregion + + + + #region PUBLIC METHODS + + public PersonCreatorRole CreateCreatorRole(long personId) => base.CreateCreatorRole(MediaId, personId); + + #endregion +} \ No newline at end of file diff --git a/WatchIt.Common/WatchIt.Common.Model/Roles/CreatorRoleQueryParameters.cs b/WatchIt.Common/WatchIt.Common.Model/Roles/CreatorRoleQueryParameters.cs new file mode 100644 index 0000000..8d416f6 --- /dev/null +++ b/WatchIt.Common/WatchIt.Common.Model/Roles/CreatorRoleQueryParameters.cs @@ -0,0 +1,25 @@ +using Microsoft.AspNetCore.Mvc; +using WatchIt.Common.Query; + +namespace WatchIt.Common.Model.Roles; + +public abstract class CreatorRoleQueryParameters : QueryParameters +{ + #region PROPERTIES + + [FromQuery(Name = "type_id")] + public short? TypeId { get; set; } + + #endregion + + + + #region PRIVATE METHODS + + protected override bool IsMeetingConditions(CreatorRoleResponse item) => + ( + Test(item.TypeId, TypeId) + ); + + #endregion +} \ No newline at end of file diff --git a/WatchIt.Common/WatchIt.Common.Model/Roles/CreatorRoleRequest.cs b/WatchIt.Common/WatchIt.Common.Model/Roles/CreatorRoleRequest.cs new file mode 100644 index 0000000..1aa45f7 --- /dev/null +++ b/WatchIt.Common/WatchIt.Common.Model/Roles/CreatorRoleRequest.cs @@ -0,0 +1,24 @@ +using WatchIt.Database.Model.Person; + +namespace WatchIt.Common.Model.Roles; + +public abstract class CreatorRoleRequest : CreatorRole, ICreatorRoleRequest +{ + #region PUBLIC METHODS + + public PersonCreatorRole CreateCreatorRole(long mediaId, long personId) => new PersonCreatorRole + { + MediaId = mediaId, + PersonId = personId, + PersonCreatorRoleTypeId = TypeId, + }; + + public void UpdateCreatorRole(PersonCreatorRole item, long mediaId, long personId) + { + item.MediaId = mediaId; + item.PersonId = personId; + item.PersonCreatorRoleTypeId = TypeId; + } + + #endregion +} \ No newline at end of file diff --git a/WatchIt.Common/WatchIt.Common.Model/Roles/CreatorRoleResponse.cs b/WatchIt.Common/WatchIt.Common.Model/Roles/CreatorRoleResponse.cs new file mode 100644 index 0000000..d0611ea --- /dev/null +++ b/WatchIt.Common/WatchIt.Common.Model/Roles/CreatorRoleResponse.cs @@ -0,0 +1,46 @@ +using System.Diagnostics.CodeAnalysis; +using System.Text.Json.Serialization; +using WatchIt.Common.Query; + +namespace WatchIt.Common.Model.Roles; + +public class CreatorRoleResponse : CreatorRole, IQueryOrderable, IRoleResponse +{ + #region PROPERTIES + + [JsonIgnore] + public static IDictionary> OrderableProperties { get; } = new Dictionary> + { + { "type_id", item => item.TypeId }, + }; + + + [JsonPropertyName("id")] + public required Guid Id { get; set; } + + [JsonPropertyName("media_id")] + public long MediaId { get; set; } + + [JsonPropertyName("person_id")] + public long PersonId { get; set; } + + #endregion + + + + #region CONSTRUCTORS + + [JsonConstructor] + public CreatorRoleResponse() {} + + [SetsRequiredMembers] + public CreatorRoleResponse(Database.Model.Person.PersonCreatorRole data) + { + Id = data.Id; + MediaId = data.MediaId; + PersonId = data.PersonId; + TypeId = data.PersonCreatorRoleTypeId; + } + + #endregion +} \ No newline at end of file diff --git a/WatchIt.Common/WatchIt.Common.Model/Roles/CreatorRoleUniversalRequest.cs b/WatchIt.Common/WatchIt.Common.Model/Roles/CreatorRoleUniversalRequest.cs new file mode 100644 index 0000000..931c794 --- /dev/null +++ b/WatchIt.Common/WatchIt.Common.Model/Roles/CreatorRoleUniversalRequest.cs @@ -0,0 +1,42 @@ +using System.Text.Json.Serialization; +using WatchIt.Database.Model.Person; + +namespace WatchIt.Common.Model.Roles; + +public class CreatorRoleUniversalRequest : CreatorRoleRequest, ICreatorRolePersonRequest, ICreatorRoleMediaRequest +{ + #region PROPERTIES + + [JsonPropertyName("person_id")] + public long PersonId { get; set; } + + [JsonPropertyName("media_id")] + public long MediaId { get; set; } + + #endregion + + + + #region CONSTRUCTORS + + public CreatorRoleUniversalRequest() { } + + public CreatorRoleUniversalRequest(CreatorRoleResponse data) + { + MediaId = data.MediaId; + PersonId = data.PersonId; + TypeId = data.TypeId; + } + + #endregion + + + + #region PUBLIC METHODS + + public PersonCreatorRole CreateCreatorRole() => base.CreateCreatorRole(MediaId, PersonId); + + public void UpdateCreatorRole(PersonCreatorRole item) => base.UpdateCreatorRole(item, MediaId, PersonId); + + #endregion +} \ No newline at end of file diff --git a/WatchIt.Common/WatchIt.Common.Model/Roles/IActorRoleMediaRequest.cs b/WatchIt.Common/WatchIt.Common.Model/Roles/IActorRoleMediaRequest.cs new file mode 100644 index 0000000..c99d824 --- /dev/null +++ b/WatchIt.Common/WatchIt.Common.Model/Roles/IActorRoleMediaRequest.cs @@ -0,0 +1,10 @@ +namespace WatchIt.Common.Model.Roles; + +public interface IActorRoleMediaRequest : IActorRoleRequest +{ + #region PROPERTIES + + public long PersonId { get; set; } + + #endregion +} \ No newline at end of file diff --git a/WatchIt.Common/WatchIt.Common.Model/Roles/IActorRolePersonRequest.cs b/WatchIt.Common/WatchIt.Common.Model/Roles/IActorRolePersonRequest.cs new file mode 100644 index 0000000..37d2dfc --- /dev/null +++ b/WatchIt.Common/WatchIt.Common.Model/Roles/IActorRolePersonRequest.cs @@ -0,0 +1,10 @@ +namespace WatchIt.Common.Model.Roles; + +public interface IActorRolePersonRequest : IActorRoleRequest +{ + #region PROPERTIES + + public long MediaId { get; set; } + + #endregion +} \ No newline at end of file diff --git a/WatchIt.Common/WatchIt.Common.Model/Roles/IActorRoleRequest.cs b/WatchIt.Common/WatchIt.Common.Model/Roles/IActorRoleRequest.cs new file mode 100644 index 0000000..d61550f --- /dev/null +++ b/WatchIt.Common/WatchIt.Common.Model/Roles/IActorRoleRequest.cs @@ -0,0 +1,12 @@ +namespace WatchIt.Common.Model.Roles; + +public interface IActorRoleRequest +{ + #region PROPERTIES + + public short TypeId { get; set; } + + public string Name { get; set; } + + #endregion +} \ No newline at end of file diff --git a/WatchIt.Common/WatchIt.Common.Model/Roles/ICreatorRoleMediaRequest.cs b/WatchIt.Common/WatchIt.Common.Model/Roles/ICreatorRoleMediaRequest.cs new file mode 100644 index 0000000..40fb45d --- /dev/null +++ b/WatchIt.Common/WatchIt.Common.Model/Roles/ICreatorRoleMediaRequest.cs @@ -0,0 +1,10 @@ +namespace WatchIt.Common.Model.Roles; + +public interface ICreatorRoleMediaRequest : ICreatorRoleRequest +{ + #region PROPERTIES + + public long PersonId { get; set; } + + #endregion +} \ No newline at end of file diff --git a/WatchIt.Common/WatchIt.Common.Model/Roles/ICreatorRolePersonRequest.cs b/WatchIt.Common/WatchIt.Common.Model/Roles/ICreatorRolePersonRequest.cs new file mode 100644 index 0000000..2e569e5 --- /dev/null +++ b/WatchIt.Common/WatchIt.Common.Model/Roles/ICreatorRolePersonRequest.cs @@ -0,0 +1,10 @@ +namespace WatchIt.Common.Model.Roles; + +public interface ICreatorRolePersonRequest : ICreatorRoleRequest +{ + #region PROPERTIES + + public long MediaId { get; set; } + + #endregion +} \ No newline at end of file diff --git a/WatchIt.Common/WatchIt.Common.Model/Roles/ICreatorRoleRequest.cs b/WatchIt.Common/WatchIt.Common.Model/Roles/ICreatorRoleRequest.cs new file mode 100644 index 0000000..150eba0 --- /dev/null +++ b/WatchIt.Common/WatchIt.Common.Model/Roles/ICreatorRoleRequest.cs @@ -0,0 +1,10 @@ +namespace WatchIt.Common.Model.Roles; + +public interface ICreatorRoleRequest +{ + #region PROPERTIES + + public short TypeId { get; set; } + + #endregion +} \ No newline at end of file diff --git a/WatchIt.Common/WatchIt.Common.Model/Roles/IRoleResponse.cs b/WatchIt.Common/WatchIt.Common.Model/Roles/IRoleResponse.cs new file mode 100644 index 0000000..dbd62e3 --- /dev/null +++ b/WatchIt.Common/WatchIt.Common.Model/Roles/IRoleResponse.cs @@ -0,0 +1,9 @@ +namespace WatchIt.Common.Model.Roles; + +public interface IRoleResponse +{ + Guid Id { get; set; } + long MediaId { get; set; } + long PersonId { get; set; } + short TypeId { get; set; } +} \ No newline at end of file diff --git a/WatchIt.Common/WatchIt.Common.Model/Roles/RoleType.cs b/WatchIt.Common/WatchIt.Common.Model/Roles/RoleType.cs new file mode 100644 index 0000000..cb3ed4e --- /dev/null +++ b/WatchIt.Common/WatchIt.Common.Model/Roles/RoleType.cs @@ -0,0 +1,13 @@ +using System.Text.Json.Serialization; + +namespace WatchIt.Common.Model.Roles; + +public class RoleType +{ + #region PROPERTIES + + [JsonPropertyName("name")] + public required string Name { get; set; } + + #endregion +} \ No newline at end of file diff --git a/WatchIt.Common/WatchIt.Common.Model/Roles/RoleTypeQueryParameters.cs b/WatchIt.Common/WatchIt.Common.Model/Roles/RoleTypeQueryParameters.cs new file mode 100644 index 0000000..2198ee9 --- /dev/null +++ b/WatchIt.Common/WatchIt.Common.Model/Roles/RoleTypeQueryParameters.cs @@ -0,0 +1,22 @@ +using Microsoft.AspNetCore.Mvc; +using WatchIt.Common.Query; + +namespace WatchIt.Common.Model.Roles; + +public class RoleTypeQueryParameters : QueryParameters +{ + #region PROPERTIES + + [FromQuery(Name = "name")] + public string? Name { get; set; } + + #endregion + + + + #region PRIVATE METHODS + + protected override bool IsMeetingConditions(RoleTypeResponse item) => TestStringWithRegex(item.Name, Name); + + #endregion +} \ No newline at end of file diff --git a/WatchIt.Common/WatchIt.Common.Model/Roles/RoleTypeRequest.cs b/WatchIt.Common/WatchIt.Common.Model/Roles/RoleTypeRequest.cs new file mode 100644 index 0000000..cfefe02 --- /dev/null +++ b/WatchIt.Common/WatchIt.Common.Model/Roles/RoleTypeRequest.cs @@ -0,0 +1,18 @@ +namespace WatchIt.Common.Model.Roles; + +public class RoleTypeRequest : RoleType +{ + #region PUBLIC METHODS + + public Database.Model.Person.PersonActorRoleType CreateActorRoleType() => new Database.Model.Person.PersonActorRoleType() + { + Name = Name + }; + + public Database.Model.Person.PersonCreatorRoleType CreateCreatorRoleType() => new Database.Model.Person.PersonCreatorRoleType() + { + Name = Name + }; + + #endregion +} \ No newline at end of file diff --git a/WatchIt.Common/WatchIt.Common.Model/Roles/RoleTypeResponse.cs b/WatchIt.Common/WatchIt.Common.Model/Roles/RoleTypeResponse.cs new file mode 100644 index 0000000..2b3dbe6 --- /dev/null +++ b/WatchIt.Common/WatchIt.Common.Model/Roles/RoleTypeResponse.cs @@ -0,0 +1,45 @@ +using System.Diagnostics.CodeAnalysis; +using System.Text.Json.Serialization; +using WatchIt.Common.Query; + +namespace WatchIt.Common.Model.Roles; + +public class RoleTypeResponse : RoleType, IQueryOrderable +{ + #region PROPERTIES + + [JsonIgnore] + public static IDictionary> OrderableProperties { get; } = new Dictionary> + { + { "name", item => item.Name } + }; + + + [JsonPropertyName("id")] + public required short Id { get; set; } + + #endregion + + + + #region CONSTRUCTORS + + [JsonConstructor] + public RoleTypeResponse() { } + + [SetsRequiredMembers] + public RoleTypeResponse(Database.Model.Person.PersonCreatorRoleType creatorRoleType) + { + Id = creatorRoleType.Id; + Name = creatorRoleType.Name; + } + + [SetsRequiredMembers] + public RoleTypeResponse(Database.Model.Person.PersonActorRoleType actorRoleType) + { + Id = actorRoleType.Id; + Name = actorRoleType.Name; + } + + #endregion +} \ No newline at end of file diff --git a/WatchIt.Common/WatchIt.Common.Model/Series/SeriesQueryParameters.cs b/WatchIt.Common/WatchIt.Common.Model/Series/SeriesQueryParameters.cs index f4594c0..164a029 100644 --- a/WatchIt.Common/WatchIt.Common.Model/Series/SeriesQueryParameters.cs +++ b/WatchIt.Common/WatchIt.Common.Model/Series/SeriesQueryParameters.cs @@ -59,9 +59,9 @@ public class SeriesQueryParameters : QueryParameters - #region PUBLIC METHODS + #region PRIVATE METHODS - public override bool IsMeetingConditions(SeriesResponse item) => + protected override bool IsMeetingConditions(SeriesResponse item) => ( TestStringWithRegex(item.Title, Title) && diff --git a/WatchIt.Common/WatchIt.Common.Model/Series/SeriesResponse.cs b/WatchIt.Common/WatchIt.Common.Model/Series/SeriesResponse.cs index 862d6e0..fe3fa4b 100644 --- a/WatchIt.Common/WatchIt.Common.Model/Series/SeriesResponse.cs +++ b/WatchIt.Common/WatchIt.Common.Model/Series/SeriesResponse.cs @@ -50,7 +50,7 @@ public class SeriesResponse : Series, IQueryOrderable ReleaseDate = mediaSeries.Media.ReleaseDate; Length = mediaSeries.Media.Length; HasEnded = mediaSeries.HasEnded; - Rating = new RatingResponse(mediaSeries.Media.RatingMedia); + Rating = RatingResponse.Create(mediaSeries.Media.RatingMedia); } #endregion diff --git a/WatchIt.Common/WatchIt.Common.Query/QueryParameters.cs b/WatchIt.Common/WatchIt.Common.Query/QueryParameters.cs index d946e85..c574197 100644 --- a/WatchIt.Common/WatchIt.Common.Query/QueryParameters.cs +++ b/WatchIt.Common/WatchIt.Common.Query/QueryParameters.cs @@ -122,7 +122,7 @@ public abstract class QueryParameters : QueryParameters where T : IQueryOrder { #region PUBLIC METHODS - public abstract bool IsMeetingConditions(T item); + protected abstract bool IsMeetingConditions(T item); public IEnumerable PrepareData(IEnumerable data) { diff --git a/WatchIt.Database/WatchIt.Database.Model/WatchIt.Database.Model.Configuration/Person/PersonActorRoleConfiguration.cs b/WatchIt.Database/WatchIt.Database.Model/WatchIt.Database.Model.Configuration/Person/PersonActorRoleConfiguration.cs index b94193e..b6edd76 100644 --- a/WatchIt.Database/WatchIt.Database.Model/WatchIt.Database.Model.Configuration/Person/PersonActorRoleConfiguration.cs +++ b/WatchIt.Database/WatchIt.Database.Model/WatchIt.Database.Model.Configuration/Person/PersonActorRoleConfiguration.cs @@ -34,5 +34,9 @@ public class PersonActorRoleConfiguration : IEntityTypeConfiguration x.PersonActorRoleTypeId) .IsRequired(); + + builder.Property(x => x.RoleName) + .HasMaxLength(100) + .IsRequired(); } } \ No newline at end of file diff --git a/WatchIt.Database/WatchIt.Database/DatabaseContext.cs b/WatchIt.Database/WatchIt.Database/DatabaseContext.cs index 977953d..d04598f 100644 --- a/WatchIt.Database/WatchIt.Database/DatabaseContext.cs +++ b/WatchIt.Database/WatchIt.Database/DatabaseContext.cs @@ -66,7 +66,7 @@ public class DatabaseContext : DbContext // Rating public virtual DbSet RatingsMedia { get; set; } public virtual DbSet RatingsPersonActorRole { get; set; } - public virtual DbSet RatingsPersonCreatorRole { get; set; } + public virtual DbSet RatingsPersonCreatorRole { get; set; } public virtual DbSet RatingsMediaSeriesSeason { get; set; } public virtual DbSet RatingsMediaSeriesEpisode { get; set; } diff --git a/WatchIt.WebAPI/WatchIt.WebAPI.Controllers/GendersController.cs b/WatchIt.WebAPI/WatchIt.WebAPI.Controllers/GendersController.cs new file mode 100644 index 0000000..4f6e24d --- /dev/null +++ b/WatchIt.WebAPI/WatchIt.WebAPI.Controllers/GendersController.cs @@ -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), StatusCodes.Status200OK)] + public async Task GetAllGenders(GenderQueryParameters query) => await _gendersControllerService.GetAllGenders(query); + + [HttpGet("{id}")] + [AllowAnonymous] + [ProducesResponseType(typeof(GenderResponse), StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status404NotFound)] + public async Task 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 PostGender([FromBody]GenderRequest body) => await _gendersControllerService.PostGender(body); + + [HttpDelete("{id}")] + [Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)] + [ProducesResponseType(StatusCodes.Status204NoContent)] + [ProducesResponseType(typeof(void), StatusCodes.Status401Unauthorized)] + [ProducesResponseType(typeof(void), StatusCodes.Status403Forbidden)] + public async Task DeleteGender([FromRoute]short id) => await _gendersControllerService.DeleteGender(id); + + #endregion + + #endregion +} \ No newline at end of file diff --git a/WatchIt.WebAPI/WatchIt.WebAPI.Controllers/MediaController.cs b/WatchIt.WebAPI/WatchIt.WebAPI.Controllers/MediaController.cs index 0a095e1..6764675 100644 --- a/WatchIt.WebAPI/WatchIt.WebAPI.Controllers/MediaController.cs +++ b/WatchIt.WebAPI/WatchIt.WebAPI.Controllers/MediaController.cs @@ -6,6 +6,7 @@ using WatchIt.Common.Model.Genres; using WatchIt.Common.Model.Media; using WatchIt.Common.Model.Photos; using WatchIt.Common.Model.Rating; +using WatchIt.Common.Model.Roles; using WatchIt.WebAPI.Services.Controllers.Media; namespace WatchIt.WebAPI.Controllers; @@ -37,6 +38,11 @@ public class MediaController : ControllerBase #region Main + [HttpGet] + [AllowAnonymous] + [ProducesResponseType(typeof(IEnumerable), StatusCodes.Status200OK)] + public async Task GetAllMedia(MediaQueryParameters query) => await _mediaControllerService.GetAllMedia(query); + [HttpGet("{id}")] [AllowAnonymous] [ProducesResponseType(typeof(MediaResponse), StatusCodes.Status200OK)] @@ -160,6 +166,40 @@ public class MediaController : ControllerBase [ProducesResponseType(StatusCodes.Status404NotFound)] public async Task PostPhoto([FromRoute]long id, [FromBody]MediaPhotoRequest body) => await _mediaControllerService.PostMediaPhoto(id, body); + #endregion + + #region Roles + + [HttpGet("{id}/roles/actor")] + [AllowAnonymous] + [ProducesResponseType(typeof(IEnumerable), StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status404NotFound)] + public async Task GetMediaAllActorRoles([FromRoute]long id, ActorRoleMediaQueryParameters query) => await _mediaControllerService.GetMediaAllActorRoles(id, query); + + [HttpPost("{id}/roles/actor")] + [Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)] + [ProducesResponseType(typeof(ActorRoleResponse), StatusCodes.Status201Created)] + [ProducesResponseType(StatusCodes.Status400BadRequest)] + [ProducesResponseType(typeof(void), StatusCodes.Status401Unauthorized)] + [ProducesResponseType(typeof(void), StatusCodes.Status403Forbidden)] + [ProducesResponseType(StatusCodes.Status404NotFound)] + public async Task PostMediaActorRole([FromRoute]long id, [FromBody]ActorRoleMediaRequest body) => await _mediaControllerService.PostMediaActorRole(id, body); + + [HttpGet("{id}/roles/creator")] + [AllowAnonymous] + [ProducesResponseType(typeof(IEnumerable), StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status404NotFound)] + public async Task GetMediaAllCreatorRoles([FromRoute]long id, CreatorRoleMediaQueryParameters query) => await _mediaControllerService.GetMediaAllCreatorRoles(id, query); + + [HttpPost("{id}/roles/creator")] + [Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)] + [ProducesResponseType(typeof(CreatorRoleResponse), StatusCodes.Status201Created)] + [ProducesResponseType(StatusCodes.Status400BadRequest)] + [ProducesResponseType(typeof(void), StatusCodes.Status401Unauthorized)] + [ProducesResponseType(typeof(void), StatusCodes.Status403Forbidden)] + [ProducesResponseType(StatusCodes.Status404NotFound)] + public async Task PostMediaCreatorRole([FromRoute]long id, [FromBody]CreatorRoleMediaRequest body) => await _mediaControllerService.PostMediaCreatorRole(id, body); + #endregion #endregion diff --git a/WatchIt.WebAPI/WatchIt.WebAPI.Controllers/PersonsController.cs b/WatchIt.WebAPI/WatchIt.WebAPI.Controllers/PersonsController.cs new file mode 100644 index 0000000..ed213b0 --- /dev/null +++ b/WatchIt.WebAPI/WatchIt.WebAPI.Controllers/PersonsController.cs @@ -0,0 +1,168 @@ +using Microsoft.AspNetCore.Authentication.JwtBearer; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using WatchIt.Common.Model.Persons; +using WatchIt.Common.Model.Rating; +using WatchIt.Common.Model.Roles; +using WatchIt.WebAPI.Services.Controllers.Persons; + +namespace WatchIt.WebAPI.Controllers; + +[ApiController] +[Route("persons")] +public class PersonsController : ControllerBase +{ + #region SERVICES + + private readonly IPersonsControllerService _personsControllerService; + + #endregion + + + + #region CONSTRUCTORS + + public PersonsController(IPersonsControllerService personsControllerService) + { + _personsControllerService = personsControllerService; + } + + #endregion + + + + #region METHODS + + #region Main + + [HttpGet] + [AllowAnonymous] + [ProducesResponseType(typeof(IEnumerable), StatusCodes.Status200OK)] + public async Task GetAllMovies(PersonQueryParameters query) => await _personsControllerService.GetAllPersons(query); + + [HttpGet("{id}")] + [AllowAnonymous] + [ProducesResponseType(typeof(PersonResponse), StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status404NotFound)] + public async Task GetMovie([FromRoute] long id) => await _personsControllerService.GetPerson(id); + + [HttpPost] + [Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)] + [ProducesResponseType(typeof(PersonResponse), StatusCodes.Status201Created)] + [ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)] + [ProducesResponseType(typeof(void), StatusCodes.Status401Unauthorized)] + [ProducesResponseType(typeof(void), StatusCodes.Status403Forbidden)] + public async Task PostMovie([FromBody] PersonRequest body) => await _personsControllerService.PostPerson(body); + + [HttpPut("{id}")] + [Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)] + [ProducesResponseType(typeof(void), StatusCodes.Status200OK)] + [ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)] + [ProducesResponseType(typeof(void), StatusCodes.Status401Unauthorized)] + [ProducesResponseType(typeof(void), StatusCodes.Status403Forbidden)] + public async Task PutMovie([FromRoute] long id, [FromBody]PersonRequest body) => await _personsControllerService.PutPerson(id, body); + + [HttpDelete("{id}")] + [Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)] + [ProducesResponseType(typeof(void), StatusCodes.Status204NoContent)] + [ProducesResponseType(typeof(void), StatusCodes.Status401Unauthorized)] + [ProducesResponseType(typeof(void), StatusCodes.Status403Forbidden)] + public async Task DeleteMovie([FromRoute] long id) => await _personsControllerService.DeletePerson(id); + + #endregion + + #region View count + + [HttpGet("view")] + [AllowAnonymous] + [ProducesResponseType(typeof(IEnumerable), StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status400BadRequest)] + public async Task GetPersonsViewRank([FromQuery] int first = 5, [FromQuery] int days = 7) => await _personsControllerService.GetPersonsViewRank(first, days); + + [HttpPost("{id}/view")] + [AllowAnonymous] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status404NotFound)] + public async Task PostPersonsView([FromRoute] long id) => await _personsControllerService.PostPersonsView(id); + + #endregion + + #region Photo + + [HttpGet("{id}/photo")] + [AllowAnonymous] + [ProducesResponseType(typeof(PersonPhotoResponse), StatusCodes.Status200OK)] + [ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)] + [ProducesResponseType(StatusCodes.Status404NotFound)] + public async Task 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 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 DeletePersonPhoto([FromRoute]long id) => await _personsControllerService.DeletePersonPhoto(id); + + #endregion + + #region Roles + + [HttpGet("{id}/roles/actor")] + [AllowAnonymous] + [ProducesResponseType(typeof(IEnumerable), StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status404NotFound)] + public async Task GetPersonAllActorRoles([FromRoute]long id, ActorRolePersonQueryParameters query) => await _personsControllerService.GetPersonAllActorRoles(id, query); + + [HttpPost("{id}/roles/actor")] + [Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)] + [ProducesResponseType(typeof(ActorRoleResponse), StatusCodes.Status201Created)] + [ProducesResponseType(StatusCodes.Status400BadRequest)] + [ProducesResponseType(typeof(void), StatusCodes.Status401Unauthorized)] + [ProducesResponseType(typeof(void), StatusCodes.Status403Forbidden)] + [ProducesResponseType(StatusCodes.Status404NotFound)] + public async Task PostPersonActorRole([FromRoute]long id, [FromBody]ActorRolePersonRequest body) => await _personsControllerService.PostPersonActorRole(id, body); + + [HttpGet("{id}/roles/creator")] + [AllowAnonymous] + [ProducesResponseType(typeof(IEnumerable), StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status404NotFound)] + public async Task GetPersonAllCreatorRoles([FromRoute]long id, CreatorRolePersonQueryParameters query) => await _personsControllerService.GetPersonAllCreatorRoles(id, query); + + [HttpPost("{id}/roles/creator")] + [Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)] + [ProducesResponseType(typeof(CreatorRoleResponse), StatusCodes.Status201Created)] + [ProducesResponseType(StatusCodes.Status400BadRequest)] + [ProducesResponseType(typeof(void), StatusCodes.Status401Unauthorized)] + [ProducesResponseType(typeof(void), StatusCodes.Status403Forbidden)] + [ProducesResponseType(StatusCodes.Status404NotFound)] + public async Task PostPersonCreatorRole([FromRoute]long id, [FromBody]CreatorRolePersonRequest body) => await _personsControllerService.PostPersonCreatorRole(id, body); + + #endregion + + #region Rating + + [HttpGet("{id}/rating")] + [AllowAnonymous] + [ProducesResponseType(typeof(RatingResponse), StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status404NotFound)] + public async Task GetPersonGlobalRating([FromRoute]long id) => await _personsControllerService.GetPersonGlobalRating(id); + + [HttpGet("{id}/rating/{user_id}")] + [AllowAnonymous] + [ProducesResponseType(typeof(RatingResponse), StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status404NotFound)] + public async Task GetPersonUserRating([FromRoute]long id, [FromRoute(Name = "user_id")]long userId) => await _personsControllerService.GetPersonUserRating(id, userId); + + #endregion + + #endregion +} \ No newline at end of file diff --git a/WatchIt.WebAPI/WatchIt.WebAPI.Controllers/RolesController.cs b/WatchIt.WebAPI/WatchIt.WebAPI.Controllers/RolesController.cs new file mode 100644 index 0000000..b656bd9 --- /dev/null +++ b/WatchIt.WebAPI/WatchIt.WebAPI.Controllers/RolesController.cs @@ -0,0 +1,192 @@ +using Microsoft.AspNetCore.Authentication.JwtBearer; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using WatchIt.Common.Model.Rating; +using WatchIt.Common.Model.Roles; +using WatchIt.WebAPI.Services.Controllers.Roles; + +namespace WatchIt.WebAPI.Controllers; + +[ApiController] +[Route("roles")] +public class RolesController : ControllerBase +{ + #region SERVICES + + private readonly IRolesControllerService _rolesControllerService; + + #endregion + + + + #region CONSTRUCTORS + + public RolesController(IRolesControllerService rolesControllerService) + { + _rolesControllerService = rolesControllerService; + } + + #endregion + + + + #region METHODS + + #region Actor + + [HttpGet("actor/{id}")] + [AllowAnonymous] + [ProducesResponseType(typeof(IEnumerable), StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status404NotFound)] + public async Task GetActorRole([FromRoute]Guid id) => await _rolesControllerService.GetActorRole(id); + + [HttpPut("actor/{id}")] + [Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status400BadRequest)] + [ProducesResponseType(typeof(void), StatusCodes.Status401Unauthorized)] + [ProducesResponseType(typeof(void), StatusCodes.Status403Forbidden)] + [ProducesResponseType(StatusCodes.Status404NotFound)] + public async Task PutActorRole([FromRoute]Guid id, [FromBody]ActorRoleUniversalRequest body) => await _rolesControllerService.PutActorRole(id, body); + + [HttpDelete("actor/{id}")] + [Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)] + [ProducesResponseType(StatusCodes.Status204NoContent)] + [ProducesResponseType(typeof(void), StatusCodes.Status401Unauthorized)] + [ProducesResponseType(typeof(void), StatusCodes.Status403Forbidden)] + public async Task DeleteActorRole([FromRoute]Guid id) => await _rolesControllerService.DeleteActorRole(id); + + [HttpGet("actor/{id}/rating")] + [AllowAnonymous] + [ProducesResponseType(typeof(RatingResponse), StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status404NotFound)] + public async Task GetActorRoleRating([FromRoute] Guid id) => await _rolesControllerService.GetActorRoleRating(id); + + [HttpGet("actor/{id}/rating/{user_id}")] + [AllowAnonymous] + [ProducesResponseType(typeof(short), StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status404NotFound)] + public async Task GetActorRoleRatingByUser([FromRoute] Guid id, [FromRoute(Name = "user_id")]long userId) => await _rolesControllerService.GetActorRoleRatingByUser(id, userId); + + [HttpPut("actor/{id}/rating")] + [Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status400BadRequest)] + [ProducesResponseType(typeof(void), StatusCodes.Status401Unauthorized)] + [ProducesResponseType(StatusCodes.Status404NotFound)] + public async Task PutActorRoleRating([FromRoute] Guid id, [FromBody] RatingRequest data) => await _rolesControllerService.PutActorRoleRating(id, data); + + [HttpDelete("actor/{id}/rating")] + [Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(typeof(void), StatusCodes.Status401Unauthorized)] + public async Task DeleteActorRoleRating([FromRoute] Guid id) => await _rolesControllerService.DeleteActorRoleRating(id); + + [HttpGet("actor/type")] + [AllowAnonymous] + [ProducesResponseType(typeof(IEnumerable), StatusCodes.Status200OK)] + public async Task GetAllActorRoleTypes(RoleTypeQueryParameters query) => await _rolesControllerService.GetAllActorRoleTypes(query); + + [HttpGet("actor/type/{type_id}")] + [AllowAnonymous] + [ProducesResponseType(typeof(RoleTypeResponse), StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status404NotFound)] + public async Task GetActorRoleType([FromRoute(Name = "type_id")]short typeId) => await _rolesControllerService.GetActorRoleType(typeId); + + [HttpPost("actor/type")] + [Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)] + [ProducesResponseType(typeof(RoleTypeResponse), StatusCodes.Status201Created)] + [ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)] + [ProducesResponseType(typeof(void), StatusCodes.Status401Unauthorized)] + [ProducesResponseType(typeof(void), StatusCodes.Status403Forbidden)] + public async Task PostActorRoleType([FromBody]RoleTypeRequest body) => await _rolesControllerService.PostActorRoleType(body); + + [HttpDelete("actor/type/{type_id}")] + [Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)] + [ProducesResponseType(StatusCodes.Status204NoContent)] + [ProducesResponseType(typeof(void), StatusCodes.Status401Unauthorized)] + [ProducesResponseType(typeof(void), StatusCodes.Status403Forbidden)] + public async Task DeleteActorRoleType([FromRoute(Name = "type_id")]short typeId) => await _rolesControllerService.DeleteActorRoleType(typeId); + + #endregion + + #region Creator + + [HttpGet("creator/{id}")] + [AllowAnonymous] + [ProducesResponseType(typeof(IEnumerable), StatusCodes.Status200OK)] + public async Task GetCreatorRole([FromRoute]Guid id) => await _rolesControllerService.GetCreatorRole(id); + + [HttpPut("creator/{id}")] + [Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status400BadRequest)] + [ProducesResponseType(typeof(void), StatusCodes.Status401Unauthorized)] + [ProducesResponseType(typeof(void), StatusCodes.Status403Forbidden)] + [ProducesResponseType(StatusCodes.Status404NotFound)] + public async Task PutCreatorRole([FromRoute]Guid id, [FromBody]CreatorRoleUniversalRequest body) => await _rolesControllerService.PutCreatorRole(id, body); + + [HttpDelete("creator/{id}")] + [Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)] + [ProducesResponseType(StatusCodes.Status204NoContent)] + [ProducesResponseType(typeof(void), StatusCodes.Status401Unauthorized)] + [ProducesResponseType(typeof(void), StatusCodes.Status403Forbidden)] + public async Task DeleteCreatorRole([FromRoute]Guid id) => await _rolesControllerService.DeleteCreatorRole(id); + + [HttpGet("creator/{id}/rating")] + [AllowAnonymous] + [ProducesResponseType(typeof(RatingResponse), StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status404NotFound)] + public async Task GetCreatorRoleRating([FromRoute] Guid id) => await _rolesControllerService.GetCreatorRoleRating(id); + + [HttpGet("creator/{id}/rating/{user_id}")] + [AllowAnonymous] + [ProducesResponseType(typeof(short), StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status404NotFound)] + public async Task GetCreatorRoleRatingByUser([FromRoute] Guid id, [FromRoute(Name = "user_id")] long userId) => await _rolesControllerService.GetCreatorRoleRatingByUser(id, userId); + + [HttpPut("creator/{id}/rating")] + [Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status400BadRequest)] + [ProducesResponseType(typeof(void), StatusCodes.Status401Unauthorized)] + [ProducesResponseType(StatusCodes.Status404NotFound)] + public async Task PutCreatorRoleRating([FromRoute] Guid id, [FromBody] RatingRequest data) => await _rolesControllerService.PutCreatorRoleRating(id, data); + + [HttpDelete("creator/{id}/rating")] + [Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(typeof(void), StatusCodes.Status401Unauthorized)] + public async Task DeleteCreatorRoleRating([FromRoute] Guid id) => await _rolesControllerService.DeleteCreatorRoleRating(id); + + [HttpGet("creator/type")] + [AllowAnonymous] + [ProducesResponseType(typeof(IEnumerable), StatusCodes.Status200OK)] + public async Task GetAllCreatorRoleTypes(RoleTypeQueryParameters query) => await _rolesControllerService.GetAllCreatorRoleTypes(query); + + [HttpGet("creator/type/{id}")] + [AllowAnonymous] + [ProducesResponseType(typeof(RoleTypeResponse), StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status404NotFound)] + public async Task GetCreatorRoleType([FromRoute]short id) => await _rolesControllerService.GetCreatorRoleType(id); + + [HttpPost("creator/type")] + [Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)] + [ProducesResponseType(typeof(RoleTypeResponse), StatusCodes.Status201Created)] + [ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)] + [ProducesResponseType(typeof(void), StatusCodes.Status401Unauthorized)] + [ProducesResponseType(typeof(void), StatusCodes.Status403Forbidden)] + public async Task PostCreatorRoleType([FromBody]RoleTypeRequest body) => await _rolesControllerService.PostCreatorRoleType(body); + + [HttpDelete("creator/type/{id}")] + [Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)] + [ProducesResponseType(StatusCodes.Status204NoContent)] + [ProducesResponseType(typeof(void), StatusCodes.Status401Unauthorized)] + [ProducesResponseType(typeof(void), StatusCodes.Status403Forbidden)] + public async Task DeleteCreatorRoleType([FromRoute]short id) => await _rolesControllerService.DeleteCreatorRoleType(id); + + #endregion + + #endregion +} \ No newline at end of file diff --git a/WatchIt.WebAPI/WatchIt.WebAPI.Controllers/WatchIt.WebAPI.Controllers.csproj b/WatchIt.WebAPI/WatchIt.WebAPI.Controllers/WatchIt.WebAPI.Controllers.csproj index 809068e..c2ab0dd 100644 --- a/WatchIt.WebAPI/WatchIt.WebAPI.Controllers/WatchIt.WebAPI.Controllers.csproj +++ b/WatchIt.WebAPI/WatchIt.WebAPI.Controllers/WatchIt.WebAPI.Controllers.csproj @@ -14,10 +14,13 @@ + + + diff --git a/WatchIt.WebAPI/WatchIt.WebAPI.Services/WatchIt.WebAPI.Services.Controllers/WatchIt.WebAPI.Services.Controllers.Genders/GendersControllerService.cs b/WatchIt.WebAPI/WatchIt.WebAPI.Services/WatchIt.WebAPI.Services.Controllers/WatchIt.WebAPI.Services.Controllers.Genders/GendersControllerService.cs new file mode 100644 index 0000000..6c7d7dc --- /dev/null +++ b/WatchIt.WebAPI/WatchIt.WebAPI.Services/WatchIt.WebAPI.Services.Controllers/WatchIt.WebAPI.Services.Controllers.Genders/GendersControllerService.cs @@ -0,0 +1,97 @@ +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 + + #region Main + + public async Task GetAllGenders(GenderQueryParameters query) + { + IEnumerable rawData = await _database.Genders.ToListAsync(); + IEnumerable data = rawData.Select(x => new GenderResponse(x)); + data = query.PrepareData(data); + return RequestResult.Ok(data); + } + + public async Task 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 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 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 + + #endregion +} \ No newline at end of file diff --git a/WatchIt.WebAPI/WatchIt.WebAPI.Services/WatchIt.WebAPI.Services.Controllers/WatchIt.WebAPI.Services.Controllers.Genders/IGendersControllerService.cs b/WatchIt.WebAPI/WatchIt.WebAPI.Services/WatchIt.WebAPI.Services.Controllers/WatchIt.WebAPI.Services.Controllers.Genders/IGendersControllerService.cs new file mode 100644 index 0000000..92aec83 --- /dev/null +++ b/WatchIt.WebAPI/WatchIt.WebAPI.Services/WatchIt.WebAPI.Services.Controllers/WatchIt.WebAPI.Services.Controllers.Genders/IGendersControllerService.cs @@ -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 GetAllGenders(GenderQueryParameters query); + Task GetGender(short id); + Task PostGender(GenderRequest data); + Task DeleteGender(short id); +} \ No newline at end of file diff --git a/WatchIt.WebAPI/WatchIt.WebAPI.Services/WatchIt.WebAPI.Services.Controllers/WatchIt.WebAPI.Services.Controllers.Genders/WatchIt.WebAPI.Services.Controllers.Genders.csproj b/WatchIt.WebAPI/WatchIt.WebAPI.Services/WatchIt.WebAPI.Services.Controllers/WatchIt.WebAPI.Services.Controllers.Genders/WatchIt.WebAPI.Services.Controllers.Genders.csproj new file mode 100644 index 0000000..9e4603e --- /dev/null +++ b/WatchIt.WebAPI/WatchIt.WebAPI.Services/WatchIt.WebAPI.Services.Controllers/WatchIt.WebAPI.Services.Controllers.Genders/WatchIt.WebAPI.Services.Controllers.Genders.csproj @@ -0,0 +1,16 @@ + + + + net8.0 + enable + enable + + + + + + + + + + diff --git a/WatchIt.WebAPI/WatchIt.WebAPI.Services/WatchIt.WebAPI.Services.Controllers/WatchIt.WebAPI.Services.Controllers.Media/IMediaControllerService.cs b/WatchIt.WebAPI/WatchIt.WebAPI.Services/WatchIt.WebAPI.Services.Controllers/WatchIt.WebAPI.Services.Controllers.Media/IMediaControllerService.cs index a93a938..8b073a0 100644 --- a/WatchIt.WebAPI/WatchIt.WebAPI.Services/WatchIt.WebAPI.Services.Controllers/WatchIt.WebAPI.Services.Controllers.Media/IMediaControllerService.cs +++ b/WatchIt.WebAPI/WatchIt.WebAPI.Services/WatchIt.WebAPI.Services.Controllers/WatchIt.WebAPI.Services.Controllers.Media/IMediaControllerService.cs @@ -1,12 +1,14 @@ using WatchIt.Common.Model.Media; using WatchIt.Common.Model.Photos; using WatchIt.Common.Model.Rating; +using WatchIt.Common.Model.Roles; using WatchIt.WebAPI.Services.Controllers.Common; namespace WatchIt.WebAPI.Services.Controllers.Media; public interface IMediaControllerService { + Task GetAllMedia(MediaQueryParameters query); Task GetMedia(long mediaId); Task GetMediaGenres(long mediaId); @@ -27,4 +29,9 @@ public interface IMediaControllerService Task GetMediaPhotos(long mediaId, PhotoQueryParameters queryParameters); Task GetMediaPhotoRandomBackground(long mediaId); Task PostMediaPhoto(long mediaId, MediaPhotoRequest data); + + Task GetMediaAllActorRoles(long mediaId, ActorRoleMediaQueryParameters queryParameters); + Task PostMediaActorRole(long mediaId, ActorRoleMediaRequest data); + Task GetMediaAllCreatorRoles(long mediaId, CreatorRoleMediaQueryParameters queryParameters); + Task PostMediaCreatorRole(long mediaId, CreatorRoleMediaRequest data); } \ No newline at end of file diff --git a/WatchIt.WebAPI/WatchIt.WebAPI.Services/WatchIt.WebAPI.Services.Controllers/WatchIt.WebAPI.Services.Controllers.Media/MediaControllerService.cs b/WatchIt.WebAPI/WatchIt.WebAPI.Services/WatchIt.WebAPI.Services.Controllers/WatchIt.WebAPI.Services.Controllers.Media/MediaControllerService.cs index 295d923..46bde20 100644 --- a/WatchIt.WebAPI/WatchIt.WebAPI.Services/WatchIt.WebAPI.Services.Controllers/WatchIt.WebAPI.Services.Controllers.Media/MediaControllerService.cs +++ b/WatchIt.WebAPI/WatchIt.WebAPI.Services/WatchIt.WebAPI.Services.Controllers/WatchIt.WebAPI.Services.Controllers.Media/MediaControllerService.cs @@ -4,8 +4,10 @@ using WatchIt.Common.Model.Genres; using WatchIt.Common.Model.Media; using WatchIt.Common.Model.Photos; using WatchIt.Common.Model.Rating; +using WatchIt.Common.Model.Roles; using WatchIt.Database; using WatchIt.Database.Model.Media; +using WatchIt.Database.Model.Person; using WatchIt.Database.Model.Rating; using WatchIt.Database.Model.ViewCount; using WatchIt.WebAPI.Services.Controllers.Common; @@ -19,6 +21,14 @@ public class MediaControllerService(DatabaseContext database, IUserService userS #region Main + public async Task GetAllMedia(MediaQueryParameters query) + { + IEnumerable rawData = await database.Media.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); + } + public async Task GetMedia(long mediaId) { Database.Model.Media.Media? item = await database.Media.FirstOrDefaultAsync(x => x.Id == mediaId); @@ -108,36 +118,24 @@ public class MediaControllerService(DatabaseContext database, IUserService userS return RequestResult.NotFound(); } - RatingResponse ratingResponse = new RatingResponse(item.RatingMedia); + RatingResponse ratingResponse = RatingResponse.Create(item.RatingMedia); return RequestResult.Ok(ratingResponse); } public async Task GetMediaRatingByUser(long mediaId, long userId) { - Database.Model.Media.Media? item = await database.Media.FirstOrDefaultAsync(x => x.Id == mediaId); - if (item is null) + RatingMedia? rating = await database.RatingsMedia.FirstOrDefaultAsync(x => x.MediaId == mediaId && x.AccountId == userId); + if (rating is null) { return RequestResult.NotFound(); } - short? rating = item.RatingMedia.FirstOrDefault(x => x.AccountId == userId)?.Rating; - if (!rating.HasValue) - { - return RequestResult.NotFound(); - } - - return RequestResult.Ok(rating.Value); + return RequestResult.Ok(rating.Rating); } public async Task PutMediaRating(long mediaId, RatingRequest data) { - short ratingValue = data.Rating; - if (ratingValue < 1 || ratingValue > 10) - { - return RequestResult.BadRequest(); - } - Database.Model.Media.Media? item = await database.Media.FirstOrDefaultAsync(x => x.Id == mediaId); if (item is null) { @@ -149,7 +147,7 @@ public class MediaControllerService(DatabaseContext database, IUserService userS RatingMedia? rating = item.RatingMedia.FirstOrDefault(x => x.AccountId == userId); if (rating is not null) { - rating.Rating = ratingValue; + rating.Rating = data.Rating; } else { @@ -157,7 +155,7 @@ public class MediaControllerService(DatabaseContext database, IUserService userS { AccountId = userId, MediaId = mediaId, - Rating = ratingValue + Rating = data.Rating }; await database.RatingsMedia.AddAsync(rating); } @@ -267,7 +265,7 @@ public class MediaControllerService(DatabaseContext database, IUserService userS await database.SaveChangesAsync(); - MediaPosterResponse returnData = new MediaPosterResponse(media.MediaPosterImage); + MediaPosterResponse returnData = new MediaPosterResponse(media.MediaPosterImage!); return RequestResult.Ok(returnData); } @@ -351,5 +349,79 @@ public class MediaControllerService(DatabaseContext database, IUserService userS #endregion + #region Roles + + public async Task GetMediaAllActorRoles(long mediaId, ActorRoleMediaQueryParameters queryParameters) + { + Database.Model.Media.Media? media = await database.Media.FirstOrDefaultAsync(x => x.Id == mediaId); + if (media is null) + { + return RequestResult.NotFound(); + } + + IEnumerable dataRaw = await database.PersonActorRoles.Where(x => x.MediaId == mediaId).ToListAsync(); + IEnumerable data = dataRaw.Select(x => new ActorRoleResponse(x)); + data = queryParameters.PrepareData(data); + return RequestResult.Ok(data); + } + + public async Task PostMediaActorRole(long mediaId, ActorRoleMediaRequest data) + { + UserValidator validator = userService.GetValidator().MustBeAdmin(); + if (!validator.IsValid) + { + return RequestResult.Forbidden(); + } + + Database.Model.Media.Media? media = await database.Media.FirstOrDefaultAsync(x => x.Id == mediaId); + if (media is null) + { + return RequestResult.NotFound(); + } + + PersonActorRole item = data.CreateActorRole(mediaId); + await database.PersonActorRoles.AddAsync(item); + await database.SaveChangesAsync(); + + return RequestResult.Created($"roles/actor/{item.Id}", new ActorRoleResponse(item)); + } + + public async Task GetMediaAllCreatorRoles(long mediaId, CreatorRoleMediaQueryParameters queryParameters) + { + Database.Model.Media.Media? media = await database.Media.FirstOrDefaultAsync(x => x.Id == mediaId); + if (media is null) + { + return RequestResult.NotFound(); + } + + IEnumerable dataRaw = await database.PersonCreatorRoles.Where(x => x.MediaId == mediaId).ToListAsync(); + IEnumerable data = dataRaw.Select(x => new CreatorRoleResponse(x)); + data = queryParameters.PrepareData(data); + return RequestResult.Ok(data); + } + + public async Task PostMediaCreatorRole(long mediaId, CreatorRoleMediaRequest data) + { + UserValidator validator = userService.GetValidator().MustBeAdmin(); + if (!validator.IsValid) + { + return RequestResult.Forbidden(); + } + + Database.Model.Media.Media? media = await database.Media.FirstOrDefaultAsync(x => x.Id == mediaId); + if (media is null) + { + return RequestResult.NotFound(); + } + + PersonCreatorRole item = data.CreateCreatorRole(mediaId); + await database.PersonCreatorRoles.AddAsync(item); + await database.SaveChangesAsync(); + + return RequestResult.Created($"roles/creator/{item.Id}", new CreatorRoleResponse(item)); + } + + #endregion + #endregion } \ No newline at end of file diff --git a/WatchIt.WebAPI/WatchIt.WebAPI.Services/WatchIt.WebAPI.Services.Controllers/WatchIt.WebAPI.Services.Controllers.Persons/IPersonsControllerService.cs b/WatchIt.WebAPI/WatchIt.WebAPI.Services/WatchIt.WebAPI.Services.Controllers/WatchIt.WebAPI.Services.Controllers.Persons/IPersonsControllerService.cs new file mode 100644 index 0000000..76599a3 --- /dev/null +++ b/WatchIt.WebAPI/WatchIt.WebAPI.Services/WatchIt.WebAPI.Services.Controllers/WatchIt.WebAPI.Services.Controllers.Persons/IPersonsControllerService.cs @@ -0,0 +1,29 @@ +using WatchIt.Common.Model.Persons; +using WatchIt.Common.Model.Roles; +using WatchIt.WebAPI.Services.Controllers.Common; + +namespace WatchIt.WebAPI.Services.Controllers.Persons; + +public interface IPersonsControllerService +{ + Task GetAllPersons(PersonQueryParameters query); + Task GetPerson(long id); + Task PostPerson(PersonRequest data); + Task PutPerson(long id, PersonRequest data); + Task DeletePerson(long id); + + Task GetPersonsViewRank(int first, int days); + Task PostPersonsView(long personId); + + Task GetPersonPhoto(long id); + Task PutPersonPhoto(long id, PersonPhotoRequest data); + Task DeletePersonPhoto(long id); + + Task GetPersonAllActorRoles(long personId, ActorRolePersonQueryParameters queryParameters); + Task PostPersonActorRole(long personId, ActorRolePersonRequest data); + Task GetPersonAllCreatorRoles(long personId, CreatorRolePersonQueryParameters queryParameters); + Task PostPersonCreatorRole(long personId, CreatorRolePersonRequest data); + + Task GetPersonGlobalRating(long id); + Task GetPersonUserRating(long id, long userId); +} \ No newline at end of file diff --git a/WatchIt.WebAPI/WatchIt.WebAPI.Services/WatchIt.WebAPI.Services.Controllers/WatchIt.WebAPI.Services.Controllers.Persons/PersonsControllerService.cs b/WatchIt.WebAPI/WatchIt.WebAPI.Services/WatchIt.WebAPI.Services.Controllers/WatchIt.WebAPI.Services.Controllers.Persons/PersonsControllerService.cs new file mode 100644 index 0000000..3a80110 --- /dev/null +++ b/WatchIt.WebAPI/WatchIt.WebAPI.Services/WatchIt.WebAPI.Services.Controllers/WatchIt.WebAPI.Services.Controllers.Persons/PersonsControllerService.cs @@ -0,0 +1,361 @@ +using Microsoft.EntityFrameworkCore; +using WatchIt.Common.Model.Persons; +using WatchIt.Common.Model.Rating; +using WatchIt.Common.Model.Roles; +using WatchIt.Database; +using WatchIt.Database.Model.Person; +using WatchIt.Database.Model.Rating; +using WatchIt.Database.Model.ViewCount; +using WatchIt.WebAPI.Services.Controllers.Common; +using WatchIt.WebAPI.Services.Utility.User; +using Person = WatchIt.Database.Model.Person.Person; + +namespace WatchIt.WebAPI.Services.Controllers.Persons; + +public class PersonsControllerService : IPersonsControllerService +{ + #region SERVICES + + private readonly DatabaseContext _database; + private readonly IUserService _userService; + + #endregion + + + + #region CONSTRUCTORS + + public PersonsControllerService(DatabaseContext database, IUserService userService) + { + _database = database; + _userService = userService; + } + + #endregion + + + + #region PUBLIC METHODS + + #region Main + + public async Task GetAllPersons(PersonQueryParameters query) + { + IEnumerable rawData = await _database.Persons.ToListAsync(); + IEnumerable data = rawData.Select(x => new PersonResponse(x)); + data = query.PrepareData(data); + return RequestResult.Ok(data); + } + + public async Task GetPerson(long id) + { + Person? item = await _database.Persons.FirstOrDefaultAsync(x => x.Id == id); + if (item is null) + { + return RequestResult.NotFound(); + } + + PersonResponse data = new PersonResponse(item); + return RequestResult.Ok(data); + } + + public async Task PostPerson(PersonRequest data) + { + UserValidator validator = _userService.GetValidator().MustBeAdmin(); + if (!validator.IsValid) + { + return RequestResult.Forbidden(); + } + + Person personItem = data.CreatePerson(); + await _database.Persons.AddAsync(personItem); + await _database.SaveChangesAsync(); + + return RequestResult.Created($"persons/{personItem.Id}", new PersonResponse(personItem)); + } + + public async Task PutPerson(long id, PersonRequest data) + { + UserValidator validator = _userService.GetValidator().MustBeAdmin(); + if (!validator.IsValid) + { + return RequestResult.Forbidden(); + } + + Person? item = await _database.Persons.FirstOrDefaultAsync(x => x.Id == id); + if (item is null) + { + return RequestResult.NotFound(); + } + + data.UpdatePerson(item); + + await _database.SaveChangesAsync(); + + return RequestResult.Ok(); + } + + public async Task DeletePerson(long id) + { + UserValidator validator = _userService.GetValidator().MustBeAdmin(); + if (!validator.IsValid) + { + return RequestResult.Forbidden(); + } + + Person? item = await _database.Persons.FirstOrDefaultAsync(x => x.Id == id); + if (item is null) + { + return RequestResult.NotFound(); + } + + _database.PersonCreatorRoles.AttachRange(item.PersonCreatorRoles); + _database.PersonCreatorRoles.RemoveRange(item.PersonCreatorRoles); + _database.PersonActorRoles.AttachRange(item.PersonActorRoles); + _database.PersonActorRoles.RemoveRange(item.PersonActorRoles); + _database.ViewCountsPerson.AttachRange(item.ViewCountsPerson); + _database.ViewCountsPerson.RemoveRange(item.ViewCountsPerson); + _database.Persons.Attach(item); + _database.Persons.Remove(item); + await _database.SaveChangesAsync(); + + return RequestResult.NoContent(); + } + + #endregion + + #region View count + + public async Task GetPersonsViewRank(int first, int days) + { + if (first < 1 || days < 1) + { + return RequestResult.BadRequest(); + } + + DateOnly startDate = DateOnly.FromDateTime(DateTime.Now).AddDays(-days); + IEnumerable rawData = await _database.Persons.OrderByDescending(x => x.ViewCountsPerson.Where(y => y.Date >= startDate) + .Sum(y => y.ViewCount)) + .ThenBy(x => x.Id) + .Take(first) + .ToListAsync(); + + IEnumerable data = rawData.Select(x => new PersonResponse(x)); + + return RequestResult.Ok(data); + } + + public async Task PostPersonsView(long personId) + { + Database.Model.Media.Media? item = await _database.Media.FirstOrDefaultAsync(x => x.Id == personId); + if (item is null) + { + return RequestResult.NotFound(); + } + + DateOnly dateNow = DateOnly.FromDateTime(DateTime.Now); + ViewCountPerson? viewCount = await _database.ViewCountsPerson.FirstOrDefaultAsync(x => x.PersonId == personId && x.Date == dateNow); + if (viewCount is null) + { + viewCount = new ViewCountPerson + { + PersonId = personId, + Date = dateNow, + ViewCount = 1 + }; + await _database.ViewCountsPerson.AddAsync(viewCount); + } + else + { + viewCount.ViewCount++; + } + await _database.SaveChangesAsync(); + + return RequestResult.Ok(); + } + + #endregion + + #region Photo + + public async Task 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 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 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 + + #region Roles + + public async Task GetPersonAllActorRoles(long personId, ActorRolePersonQueryParameters queryParameters) + { + Database.Model.Person.Person? person = await _database.Persons.FirstOrDefaultAsync(x => x.Id == personId); + if (person is null) + { + return RequestResult.NotFound(); + } + + IEnumerable dataRaw = await _database.PersonActorRoles.Where(x => x.PersonId == personId).ToListAsync(); + IEnumerable data = dataRaw.Select(x => new ActorRoleResponse(x)); + data = queryParameters.PrepareData(data); + return RequestResult.Ok(data); + } + + public async Task PostPersonActorRole(long personId, ActorRolePersonRequest data) + { + UserValidator validator = _userService.GetValidator().MustBeAdmin(); + if (!validator.IsValid) + { + return RequestResult.Forbidden(); + } + + Person? person = await _database.Persons.FirstOrDefaultAsync(x => x.Id == personId); + if (person is null) + { + return RequestResult.NotFound(); + } + + PersonActorRole item = data.CreateActorRole(personId); + await _database.PersonActorRoles.AddAsync(item); + await _database.SaveChangesAsync(); + + return RequestResult.Created($"roles/actor/{item.Id}", new ActorRoleResponse(item)); + } + + public async Task GetPersonAllCreatorRoles(long personId, CreatorRolePersonQueryParameters queryParameters) + { + Person? media = await _database.Persons.FirstOrDefaultAsync(x => x.Id == personId); + if (media is null) + { + return RequestResult.NotFound(); + } + + IEnumerable dataRaw = await _database.PersonCreatorRoles.Where(x => x.PersonId == personId).ToListAsync(); + IEnumerable data = dataRaw.Select(x => new CreatorRoleResponse(x)); + data = queryParameters.PrepareData(data); + return RequestResult.Ok(data); + } + + public async Task PostPersonCreatorRole(long personId, CreatorRolePersonRequest data) + { + UserValidator validator = _userService.GetValidator().MustBeAdmin(); + if (!validator.IsValid) + { + return RequestResult.Forbidden(); + } + + Person? media = await _database.Persons.FirstOrDefaultAsync(x => x.Id == personId); + if (media is null) + { + return RequestResult.NotFound(); + } + + PersonCreatorRole item = data.CreateCreatorRole(personId); + await _database.PersonCreatorRoles.AddAsync(item); + await _database.SaveChangesAsync(); + + return RequestResult.Created($"roles/creator/{item.Id}", new CreatorRoleResponse(item)); + } + + #endregion + + #region Rating + + public async Task GetPersonGlobalRating(long id) + { + Person? item = await _database.Persons.FirstOrDefaultAsync(x => x.Id == id); + if (item is null) + { + return RequestResult.NotFound(); + } + + RatingResponse ratingResponse = RatingResponse.Create(item.PersonActorRoles, item.PersonCreatorRoles); + + return RequestResult.Ok(ratingResponse); + } + + public async Task GetPersonUserRating(long id, long userId) + { + Person? item = await _database.Persons.FirstOrDefaultAsync(x => x.Id == id); + if (item is null) + { + return RequestResult.NotFound(); + } + + IEnumerable actorRoleRatings = item.PersonActorRoles.SelectMany(x => x.RatingPersonActorRole).Where(x => x.AccountId == userId); + IEnumerable creatorRoleRatings = item.PersonCreatorRoles.SelectMany(x => x.RatingPersonCreatorRole).Where(x => x.AccountId == userId); + RatingResponse ratingResponse = RatingResponse.Create(actorRoleRatings, creatorRoleRatings); + + return RequestResult.Ok(ratingResponse); + } + + #endregion + + #endregion +} \ No newline at end of file diff --git a/WatchIt.WebAPI/WatchIt.WebAPI.Services/WatchIt.WebAPI.Services.Controllers/WatchIt.WebAPI.Services.Controllers.Persons/WatchIt.WebAPI.Services.Controllers.Persons.csproj b/WatchIt.WebAPI/WatchIt.WebAPI.Services/WatchIt.WebAPI.Services.Controllers/WatchIt.WebAPI.Services.Controllers.Persons/WatchIt.WebAPI.Services.Controllers.Persons.csproj new file mode 100644 index 0000000..9e4603e --- /dev/null +++ b/WatchIt.WebAPI/WatchIt.WebAPI.Services/WatchIt.WebAPI.Services.Controllers/WatchIt.WebAPI.Services.Controllers.Persons/WatchIt.WebAPI.Services.Controllers.Persons.csproj @@ -0,0 +1,16 @@ + + + + net8.0 + enable + enable + + + + + + + + + + diff --git a/WatchIt.WebAPI/WatchIt.WebAPI.Services/WatchIt.WebAPI.Services.Controllers/WatchIt.WebAPI.Services.Controllers.Roles/IRolesControllerService.cs b/WatchIt.WebAPI/WatchIt.WebAPI.Services/WatchIt.WebAPI.Services.Controllers/WatchIt.WebAPI.Services.Controllers.Roles/IRolesControllerService.cs new file mode 100644 index 0000000..5f9f67e --- /dev/null +++ b/WatchIt.WebAPI/WatchIt.WebAPI.Services/WatchIt.WebAPI.Services.Controllers/WatchIt.WebAPI.Services.Controllers.Roles/IRolesControllerService.cs @@ -0,0 +1,32 @@ +using WatchIt.Common.Model.Rating; +using WatchIt.Common.Model.Roles; +using WatchIt.WebAPI.Services.Controllers.Common; + +namespace WatchIt.WebAPI.Services.Controllers.Roles; + +public interface IRolesControllerService +{ + Task GetActorRole(Guid id); + Task PutActorRole(Guid id, ActorRoleUniversalRequest data); + Task DeleteActorRole(Guid id); + Task GetActorRoleRating(Guid id); + Task GetActorRoleRatingByUser(Guid id, long userId); + Task PutActorRoleRating(Guid id, RatingRequest data); + Task DeleteActorRoleRating(Guid id); + Task GetAllActorRoleTypes(RoleTypeQueryParameters query); + Task GetActorRoleType(short typeId); + Task PostActorRoleType(RoleTypeRequest data); + Task DeleteActorRoleType(short typeId); + + Task GetCreatorRole(Guid id); + Task PutCreatorRole(Guid id, CreatorRoleUniversalRequest data); + Task DeleteCreatorRole(Guid id); + Task GetCreatorRoleRating(Guid id); + Task GetCreatorRoleRatingByUser(Guid id, long userId); + Task PutCreatorRoleRating(Guid id, RatingRequest data); + Task DeleteCreatorRoleRating(Guid id); + Task GetAllCreatorRoleTypes(RoleTypeQueryParameters query); + Task GetCreatorRoleType(short typeId); + Task PostCreatorRoleType(RoleTypeRequest data); + Task DeleteCreatorRoleType(short typeId); +} \ No newline at end of file diff --git a/WatchIt.WebAPI/WatchIt.WebAPI.Services/WatchIt.WebAPI.Services.Controllers/WatchIt.WebAPI.Services.Controllers.Roles/RolesControllerService.cs b/WatchIt.WebAPI/WatchIt.WebAPI.Services/WatchIt.WebAPI.Services.Controllers/WatchIt.WebAPI.Services.Controllers.Roles/RolesControllerService.cs new file mode 100644 index 0000000..d9d88c2 --- /dev/null +++ b/WatchIt.WebAPI/WatchIt.WebAPI.Services/WatchIt.WebAPI.Services.Controllers/WatchIt.WebAPI.Services.Controllers.Roles/RolesControllerService.cs @@ -0,0 +1,406 @@ +using Microsoft.EntityFrameworkCore; +using WatchIt.Common.Model.Rating; +using WatchIt.Common.Model.Roles; +using WatchIt.Database; +using WatchIt.Database.Model.Person; +using WatchIt.Database.Model.Rating; +using WatchIt.WebAPI.Services.Controllers.Common; +using WatchIt.WebAPI.Services.Utility.User; + +namespace WatchIt.WebAPI.Services.Controllers.Roles; + +public class RolesControllerService : IRolesControllerService +{ + #region SERVICES + + private readonly DatabaseContext _database; + private readonly IUserService _userService; + + #endregion + + + + #region CONSTRUCTORS + + public RolesControllerService(DatabaseContext database, IUserService userService) + { + _database = database; + _userService = userService; + } + + #endregion + + + + #region PUBLIC METHODS + + #region Actor + + public async Task GetActorRole(Guid id) + { + PersonActorRole? item = await _database.PersonActorRoles.FirstOrDefaultAsync(x => x.Id == id); + if (item is null) + { + return RequestResult.NotFound(); + } + + ActorRoleResponse data = new ActorRoleResponse(item); + return RequestResult.Ok(data); + } + + public async Task PutActorRole(Guid id, ActorRoleUniversalRequest data) + { + UserValidator validator = _userService.GetValidator().MustBeAdmin(); + if (!validator.IsValid) + { + return RequestResult.Forbidden(); + } + + PersonActorRole? item = await _database.PersonActorRoles.FirstOrDefaultAsync(x => x.Id == id); + if (item is null) + { + return RequestResult.NotFound(); + } + + data.UpdateActorRole(item); + await _database.SaveChangesAsync(); + + return RequestResult.Ok(); + } + + public async Task DeleteActorRole(Guid id) + { + UserValidator validator = _userService.GetValidator().MustBeAdmin(); + if (!validator.IsValid) + { + return RequestResult.Forbidden(); + } + + PersonActorRole? item = await _database.PersonActorRoles.FirstOrDefaultAsync(x => x.Id == id); + if (item is null) + { + return RequestResult.NoContent(); + } + + _database.PersonActorRoles.Attach(item); + _database.PersonActorRoles.Remove(item); + await _database.SaveChangesAsync(); + + return RequestResult.NoContent(); + } + + public async Task GetActorRoleRating(Guid id) + { + PersonActorRole? item = await _database.PersonActorRoles.FirstOrDefaultAsync(x => x.Id == id); + if (item is null) + { + return RequestResult.NotFound(); + } + + RatingResponse ratingResponse = RatingResponse.Create(item.RatingPersonActorRole); + + return RequestResult.Ok(ratingResponse); + } + + public async Task GetActorRoleRatingByUser(Guid id, long userId) + { + RatingPersonActorRole? rating = await _database.RatingsPersonActorRole.FirstOrDefaultAsync(x => x.PersonActorRoleId == id && x.AccountId == userId); + if (rating is null) + { + return RequestResult.NotFound(); + } + + return RequestResult.Ok(rating.Rating); + } + + public async Task PutActorRoleRating(Guid id, RatingRequest data) + { + PersonActorRole? item = await _database.PersonActorRoles.FirstOrDefaultAsync(x => x.Id == id); + if (item is null) + { + return RequestResult.NotFound(); + } + + long userId = _userService.GetUserId(); + + RatingPersonActorRole? rating = item.RatingPersonActorRole.FirstOrDefault(x => x.AccountId == userId); + if (rating is not null) + { + rating.Rating = data.Rating; + } + else + { + rating = new RatingPersonActorRole + { + AccountId = userId, + PersonActorRoleId = id, + Rating = data.Rating + }; + await _database.RatingsPersonActorRole.AddAsync(rating); + } + await _database.SaveChangesAsync(); + + return RequestResult.Ok(); + } + + public async Task DeleteActorRoleRating(Guid id) + { + long userId = _userService.GetUserId(); + + RatingPersonActorRole? item = await _database.RatingsPersonActorRole.FirstOrDefaultAsync(x => x.PersonActorRoleId == id && x.AccountId == userId); + if (item is null) + { + return RequestResult.Ok(); + } + + _database.RatingsPersonActorRole.Attach(item); + _database.RatingsPersonActorRole.Remove(item); + await _database.SaveChangesAsync(); + + return RequestResult.Ok(); + } + + public async Task GetAllActorRoleTypes(RoleTypeQueryParameters query) + { + IEnumerable rawData = await _database.PersonActorRoleTypes.ToListAsync(); + IEnumerable data = rawData.Select(x => new RoleTypeResponse(x)); + data = query.PrepareData(data); + return RequestResult.Ok(data); + } + + public async Task GetActorRoleType(short id) + { + PersonActorRoleType? item = await _database.PersonActorRoleTypes.FirstOrDefaultAsync(x => x.Id == id); + if (item is null) + { + return RequestResult.NotFound(); + } + + RoleTypeResponse data = new RoleTypeResponse(item); + return RequestResult.Ok(data); + } + + public async Task PostActorRoleType(RoleTypeRequest data) + { + UserValidator validator = _userService.GetValidator().MustBeAdmin(); + if (!validator.IsValid) + { + return RequestResult.Forbidden(); + } + + PersonActorRoleType item = data.CreateActorRoleType(); + await _database.PersonActorRoleTypes.AddAsync(item); + await _database.SaveChangesAsync(); + + return RequestResult.Created($"roles/actor/{item.Id}", new RoleTypeResponse(item)); + } + + public async Task DeleteActorRoleType(short id) + { + UserValidator validator = _userService.GetValidator().MustBeAdmin(); + if (!validator.IsValid) + { + return RequestResult.Forbidden(); + } + + PersonActorRoleType? item = await _database.PersonActorRoleTypes.FirstOrDefaultAsync(x => x.Id == id); + if (item is null) + { + return RequestResult.NoContent(); + } + + _database.PersonActorRoleTypes.Attach(item); + _database.PersonActorRoleTypes.Remove(item); + await _database.SaveChangesAsync(); + + return RequestResult.NoContent(); + } + + #endregion + + #region Creator + + public async Task GetCreatorRole(Guid id) + { + PersonCreatorRole? item = await _database.PersonCreatorRoles.FirstOrDefaultAsync(x => x.Id == id); + if (item is null) + { + return RequestResult.NotFound(); + } + + CreatorRoleResponse data = new CreatorRoleResponse(item); + return RequestResult.Ok(data); + } + + public async Task PutCreatorRole(Guid id, CreatorRoleUniversalRequest data) + { + UserValidator validator = _userService.GetValidator().MustBeAdmin(); + if (!validator.IsValid) + { + return RequestResult.Forbidden(); + } + + PersonCreatorRole? item = await _database.PersonCreatorRoles.FirstOrDefaultAsync(x => x.Id == id); + if (item is null) + { + return RequestResult.NotFound(); + } + + data.UpdateCreatorRole(item); + await _database.SaveChangesAsync(); + + return RequestResult.Ok(); + } + + public async Task DeleteCreatorRole(Guid id) + { + UserValidator validator = _userService.GetValidator().MustBeAdmin(); + if (!validator.IsValid) + { + return RequestResult.Forbidden(); + } + + PersonCreatorRole? item = await _database.PersonCreatorRoles.FirstOrDefaultAsync(x => x.Id == id); + if (item is null) + { + return RequestResult.NoContent(); + } + + _database.PersonCreatorRoles.Attach(item); + _database.PersonCreatorRoles.Remove(item); + await _database.SaveChangesAsync(); + + return RequestResult.NoContent(); + } + + public async Task GetCreatorRoleRating(Guid id) + { + PersonCreatorRole? item = await _database.PersonCreatorRoles.FirstOrDefaultAsync(x => x.Id == id); + if (item is null) + { + return RequestResult.NotFound(); + } + + RatingResponse ratingResponse = RatingResponse.Create(item.RatingPersonCreatorRole); + + return RequestResult.Ok(ratingResponse); + } + + public async Task GetCreatorRoleRatingByUser(Guid id, long userId) + { + RatingPersonCreatorRole? rating = await _database.RatingsPersonCreatorRole.FirstOrDefaultAsync(x => x.PersonCreatorRoleId == id && x.AccountId == userId); + if (rating is null) + { + return RequestResult.NotFound(); + } + + return RequestResult.Ok(rating.Rating); + } + + public async Task PutCreatorRoleRating(Guid id, RatingRequest data) + { + PersonCreatorRole? item = await _database.PersonCreatorRoles.FirstOrDefaultAsync(x => x.Id == id); + if (item is null) + { + return RequestResult.NotFound(); + } + + long userId = _userService.GetUserId(); + + RatingPersonCreatorRole? rating = item.RatingPersonCreatorRole.FirstOrDefault(x => x.AccountId == userId); + if (rating is not null) + { + rating.Rating = data.Rating; + } + else + { + rating = new RatingPersonCreatorRole + { + AccountId = userId, + PersonCreatorRoleId = id, + Rating = data.Rating + }; + await _database.RatingsPersonCreatorRole.AddAsync(rating); + } + await _database.SaveChangesAsync(); + + return RequestResult.Ok(); + } + + public async Task DeleteCreatorRoleRating(Guid id) + { + long userId = _userService.GetUserId(); + + RatingPersonCreatorRole? item = await _database.RatingsPersonCreatorRole.FirstOrDefaultAsync(x => x.PersonCreatorRoleId == id && x.AccountId == userId); + if (item is null) + { + return RequestResult.Ok(); + } + + _database.RatingsPersonCreatorRole.Attach(item); + _database.RatingsPersonCreatorRole.Remove(item); + await _database.SaveChangesAsync(); + + return RequestResult.Ok(); + } + + public async Task GetAllCreatorRoleTypes(RoleTypeQueryParameters query) + { + IEnumerable rawData = await _database.PersonCreatorRoleTypes.ToListAsync(); + IEnumerable data = rawData.Select(x => new RoleTypeResponse(x)); + data = query.PrepareData(data); + return RequestResult.Ok(data); + } + + public async Task GetCreatorRoleType(short id) + { + PersonCreatorRoleType? item = await _database.PersonCreatorRoleTypes.FirstOrDefaultAsync(x => x.Id == id); + if (item is null) + { + return RequestResult.NotFound(); + } + + RoleTypeResponse data = new RoleTypeResponse(item); + return RequestResult.Ok(data); + } + + public async Task PostCreatorRoleType(RoleTypeRequest data) + { + UserValidator validator = _userService.GetValidator().MustBeAdmin(); + if (!validator.IsValid) + { + return RequestResult.Forbidden(); + } + + PersonCreatorRoleType item = data.CreateCreatorRoleType(); + await _database.PersonCreatorRoleTypes.AddAsync(item); + await _database.SaveChangesAsync(); + + return RequestResult.Created($"roles/creator/{item.Id}", new RoleTypeResponse(item)); + } + + public async Task DeleteCreatorRoleType(short id) + { + UserValidator validator = _userService.GetValidator().MustBeAdmin(); + if (!validator.IsValid) + { + return RequestResult.Forbidden(); + } + + PersonCreatorRoleType? item = await _database.PersonCreatorRoleTypes.FirstOrDefaultAsync(x => x.Id == id); + if (item is null) + { + return RequestResult.NoContent(); + } + + _database.PersonCreatorRoleTypes.Attach(item); + _database.PersonCreatorRoleTypes.Remove(item); + await _database.SaveChangesAsync(); + + return RequestResult.NoContent(); + } + + #endregion + + #endregion +} \ No newline at end of file diff --git a/WatchIt.WebAPI/WatchIt.WebAPI.Services/WatchIt.WebAPI.Services.Controllers/WatchIt.WebAPI.Services.Controllers.Roles/WatchIt.WebAPI.Services.Controllers.Roles.csproj b/WatchIt.WebAPI/WatchIt.WebAPI.Services/WatchIt.WebAPI.Services.Controllers/WatchIt.WebAPI.Services.Controllers.Roles/WatchIt.WebAPI.Services.Controllers.Roles.csproj new file mode 100644 index 0000000..9e4603e --- /dev/null +++ b/WatchIt.WebAPI/WatchIt.WebAPI.Services/WatchIt.WebAPI.Services.Controllers/WatchIt.WebAPI.Services.Controllers.Roles/WatchIt.WebAPI.Services.Controllers.Roles.csproj @@ -0,0 +1,16 @@ + + + + net8.0 + enable + enable + + + + + + + + + + diff --git a/WatchIt.WebAPI/WatchIt.WebAPI.Validators/Persons/PersonRequestValidator.cs b/WatchIt.WebAPI/WatchIt.WebAPI.Validators/Persons/PersonRequestValidator.cs new file mode 100644 index 0000000..2f3618e --- /dev/null +++ b/WatchIt.WebAPI/WatchIt.WebAPI.Validators/Persons/PersonRequestValidator.cs @@ -0,0 +1,19 @@ +using FluentValidation; +using WatchIt.Common.Model.Persons; +using WatchIt.Database; + +namespace WatchIt.WebAPI.Validators.Persons; + +public class PersonRequestValidator : AbstractValidator +{ + 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)); + }); + } +} \ No newline at end of file diff --git a/WatchIt.WebAPI/WatchIt.WebAPI.Validators/Rating/RatingRequestValidator.cs b/WatchIt.WebAPI/WatchIt.WebAPI.Validators/Rating/RatingRequestValidator.cs new file mode 100644 index 0000000..0d300c4 --- /dev/null +++ b/WatchIt.WebAPI/WatchIt.WebAPI.Validators/Rating/RatingRequestValidator.cs @@ -0,0 +1,12 @@ +using FluentValidation; +using WatchIt.Common.Model.Rating; + +namespace WatchIt.WebAPI.Validators.Rating; + +public class RatingRequestValidator : AbstractValidator +{ + public RatingRequestValidator() + { + RuleFor(x => x.Rating).InclusiveBetween((short)1, (short)10); + } +} \ No newline at end of file diff --git a/WatchIt.WebAPI/WatchIt.WebAPI.Validators/Roles/ActorRoleMediaRequestValidator.cs b/WatchIt.WebAPI/WatchIt.WebAPI.Validators/Roles/ActorRoleMediaRequestValidator.cs new file mode 100644 index 0000000..12c2b5c --- /dev/null +++ b/WatchIt.WebAPI/WatchIt.WebAPI.Validators/Roles/ActorRoleMediaRequestValidator.cs @@ -0,0 +1,16 @@ +using FluentValidation; +using WatchIt.Common.Model.Roles; +using WatchIt.Database; + +namespace WatchIt.WebAPI.Validators.Roles; + +public class ActorRoleMediaRequestValidator : AbstractValidator +{ + public ActorRoleMediaRequestValidator(DatabaseContext database) + { + Include(new BaseActorRoleRequestValidator(database)); + RuleFor(x => x.PersonId).NotEmpty() + .NotNull() + .MustBeIn(database.Persons.Select(x => x.Id).ToList()); + } +} \ No newline at end of file diff --git a/WatchIt.WebAPI/WatchIt.WebAPI.Validators/Roles/ActorRolePersonRequestValidator.cs b/WatchIt.WebAPI/WatchIt.WebAPI.Validators/Roles/ActorRolePersonRequestValidator.cs new file mode 100644 index 0000000..c89142c --- /dev/null +++ b/WatchIt.WebAPI/WatchIt.WebAPI.Validators/Roles/ActorRolePersonRequestValidator.cs @@ -0,0 +1,16 @@ +using FluentValidation; +using WatchIt.Common.Model.Roles; +using WatchIt.Database; + +namespace WatchIt.WebAPI.Validators.Roles; + +public class ActorRolePersonRequestValidator : AbstractValidator +{ + public ActorRolePersonRequestValidator(DatabaseContext database) + { + Include(new BaseActorRoleRequestValidator(database)); + RuleFor(x => x.MediaId).NotEmpty() + .NotNull() + .MustBeIn(database.Media.Select(x => x.Id).ToList()); + } +} \ No newline at end of file diff --git a/WatchIt.WebAPI/WatchIt.WebAPI.Validators/Roles/ActorRoleUniversalRequestValidator.cs b/WatchIt.WebAPI/WatchIt.WebAPI.Validators/Roles/ActorRoleUniversalRequestValidator.cs new file mode 100644 index 0000000..d23f72d --- /dev/null +++ b/WatchIt.WebAPI/WatchIt.WebAPI.Validators/Roles/ActorRoleUniversalRequestValidator.cs @@ -0,0 +1,19 @@ +using FluentValidation; +using WatchIt.Common.Model.Roles; +using WatchIt.Database; + +namespace WatchIt.WebAPI.Validators.Roles; + +public class ActorRoleUniversalRequestValidator : AbstractValidator +{ + public ActorRoleUniversalRequestValidator(DatabaseContext database) + { + Include(new BaseActorRoleRequestValidator(database)); + RuleFor(x => x.PersonId).NotEmpty() + .NotNull() + .MustBeIn(database.Persons.Select(x => x.Id).ToList()); + RuleFor(x => x.MediaId).NotEmpty() + .NotNull() + .MustBeIn(database.Media.Select(x => x.Id).ToList()); + } +} \ No newline at end of file diff --git a/WatchIt.WebAPI/WatchIt.WebAPI.Validators/Roles/BaseActorRoleRequestValidator.cs b/WatchIt.WebAPI/WatchIt.WebAPI.Validators/Roles/BaseActorRoleRequestValidator.cs new file mode 100644 index 0000000..5ead1e0 --- /dev/null +++ b/WatchIt.WebAPI/WatchIt.WebAPI.Validators/Roles/BaseActorRoleRequestValidator.cs @@ -0,0 +1,17 @@ +using FluentValidation; +using WatchIt.Common.Model.Roles; +using WatchIt.Database; + +namespace WatchIt.WebAPI.Validators.Roles; + +public class BaseActorRoleRequestValidator : AbstractValidator +{ + public BaseActorRoleRequestValidator(DatabaseContext database) + { + RuleFor(x => x.Name).NotEmpty() + .MaximumLength(100); + RuleFor(x => x.TypeId).NotEmpty() + .NotNull() + .MustBeIn(database.PersonActorRoleTypes.Select(x => x.Id).ToList()); + } +} \ No newline at end of file diff --git a/WatchIt.WebAPI/WatchIt.WebAPI/Program.cs b/WatchIt.WebAPI/WatchIt.WebAPI/Program.cs index 7bd902b..d6c6797 100644 --- a/WatchIt.WebAPI/WatchIt.WebAPI/Program.cs +++ b/WatchIt.WebAPI/WatchIt.WebAPI/Program.cs @@ -10,10 +10,13 @@ using Microsoft.IdentityModel.JsonWebTokens; using Microsoft.IdentityModel.Tokens; using WatchIt.Database; using WatchIt.WebAPI.Services.Controllers.Accounts; +using WatchIt.WebAPI.Services.Controllers.Genders; using WatchIt.WebAPI.Services.Controllers.Genres; using WatchIt.WebAPI.Services.Controllers.Media; using WatchIt.WebAPI.Services.Controllers.Movies; +using WatchIt.WebAPI.Services.Controllers.Persons; using WatchIt.WebAPI.Services.Controllers.Photos; +using WatchIt.WebAPI.Services.Controllers.Roles; using WatchIt.WebAPI.Services.Controllers.Series; using WatchIt.WebAPI.Services.Utility.Configuration; using WatchIt.WebAPI.Services.Utility.Tokens; @@ -39,7 +42,14 @@ public static class Program using (IServiceScope scope = app.Services.CreateScope()) { - scope.ServiceProvider.GetService().Database.Migrate(); + DatabaseContext dbContext = scope.ServiceProvider.GetRequiredService(); + + while (!dbContext.Database.CanConnect()) + { + Thread.Sleep(1000); + } + + dbContext.Database.Migrate(); } if (app.Environment.IsDevelopment()) @@ -153,11 +163,14 @@ public static class Program // Controller builder.Services.AddTransient(); + builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); + builder.Services.AddTransient(); + builder.Services.AddTransient(); return builder; } diff --git a/WatchIt.WebAPI/WatchIt.WebAPI/WatchIt.WebAPI.csproj b/WatchIt.WebAPI/WatchIt.WebAPI/WatchIt.WebAPI.csproj index 5c06b61..56996dc 100644 --- a/WatchIt.WebAPI/WatchIt.WebAPI/WatchIt.WebAPI.csproj +++ b/WatchIt.WebAPI/WatchIt.WebAPI/WatchIt.WebAPI.csproj @@ -27,6 +27,8 @@ + + diff --git a/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.Utility/WatchIt.Website.Services.Utility.Configuration/Model/ConfigurationData.cs b/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.Utility/WatchIt.Website.Services.Utility.Configuration/Model/ConfigurationData.cs index cac866a..7709295 100644 --- a/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.Utility/WatchIt.Website.Services.Utility.Configuration/Model/ConfigurationData.cs +++ b/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.Utility/WatchIt.Website.Services.Utility.Configuration/Model/ConfigurationData.cs @@ -5,5 +5,6 @@ public class ConfigurationData public Logging Logging { get; set; } public string AllowedHosts { get; set; } public StorageKeys StorageKeys { get; set; } + public Style Style { get; set; } public Endpoints Endpoints { get; set; } } \ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.Utility/WatchIt.Website.Services.Utility.Configuration/Model/Endpoints.cs b/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.Utility/WatchIt.Website.Services.Utility.Configuration/Model/Endpoints.cs index 765dd46..386b6c1 100644 --- a/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.Utility/WatchIt.Website.Services.Utility.Configuration/Model/Endpoints.cs +++ b/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.Utility/WatchIt.Website.Services.Utility.Configuration/Model/Endpoints.cs @@ -4,9 +4,12 @@ public class Endpoints { public string Base { get; set; } public Accounts Accounts { get; set; } + public Genders Genders { get; set; } public Genres Genres { get; set; } public Media Media { get; set; } public Movies Movies { get; set; } public Series Series { get; set; } public Photos Photos { get; set; } + public Persons Persons { get; set; } + public Roles Roles { get; set; } } \ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.Utility/WatchIt.Website.Services.Utility.Configuration/Model/Genders.cs b/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.Utility/WatchIt.Website.Services.Utility.Configuration/Model/Genders.cs new file mode 100644 index 0000000..58a8f53 --- /dev/null +++ b/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.Utility/WatchIt.Website.Services.Utility.Configuration/Model/Genders.cs @@ -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; } +} \ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.Utility/WatchIt.Website.Services.Utility.Configuration/Model/Media.cs b/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.Utility/WatchIt.Website.Services.Utility.Configuration/Model/Media.cs index 3774ebd..a7ae025 100644 --- a/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.Utility/WatchIt.Website.Services.Utility.Configuration/Model/Media.cs +++ b/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.Utility/WatchIt.Website.Services.Utility.Configuration/Model/Media.cs @@ -3,6 +3,7 @@ public class Media { public string Base { get; set; } + public string GetAllMedia { get; set; } public string GetMedia { get; set; } public string GetMediaGenres { get; set; } public string PostMediaGenre { get; set; } @@ -18,4 +19,8 @@ public class Media public string GetMediaPhotos { get; set; } public string GetMediaPhotoRandomBackground { get; set; } public string PostMediaPhoto { get; set; } + public string GetMediaAllActorRoles { get; set; } + public string PostMediaActorRole { get; set; } + public string GetMediaAllCreatorRoles { get; set; } + public string PostMediaCreatorRole { get; set; } } \ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.Utility/WatchIt.Website.Services.Utility.Configuration/Model/Persons.cs b/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.Utility/WatchIt.Website.Services.Utility.Configuration/Model/Persons.cs new file mode 100644 index 0000000..0bbc44e --- /dev/null +++ b/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.Utility/WatchIt.Website.Services.Utility.Configuration/Model/Persons.cs @@ -0,0 +1,22 @@ +namespace WatchIt.Website.Services.Utility.Configuration.Model; + +public class Persons +{ + public string Base { get; set; } + public string GetAllPersons { get; set; } + public string GetPerson { get; set; } + public string PostPerson { get; set; } + public string PutPerson { get; set; } + public string DeletePerson { get; set; } + public string GetPersonsViewRank { get; set; } + public string PostPersonsView { get; set; } + public string GetPersonPhoto { get; set; } + public string PutPersonPhoto { get; set; } + public string DeletePersonPhoto { get; set; } + public string GetPersonAllActorRoles { get; set; } + public string PostPersonActorRole { get; set; } + public string GetPersonAllCreatorRoles { get; set; } + public string PostPersonCreatorRole { get; set; } + public string GetPersonGlobalRating { get; set; } + public string GetPersonUserRating { get; set; } +} \ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.Utility/WatchIt.Website.Services.Utility.Configuration/Model/Roles.cs b/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.Utility/WatchIt.Website.Services.Utility.Configuration/Model/Roles.cs new file mode 100644 index 0000000..6eec92e --- /dev/null +++ b/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.Utility/WatchIt.Website.Services.Utility.Configuration/Model/Roles.cs @@ -0,0 +1,28 @@ +namespace WatchIt.Website.Services.Utility.Configuration.Model; + +public class Roles +{ + public string Base { get; set; } + public string GetActorRole { get; set; } + public string PutActorRole { get; set; } + public string DeleteActorRole { get; set; } + public string GetActorRoleRating { get; set; } + public string GetActorRoleRatingByUser { get; set; } + public string PutActorRoleRating { get; set; } + public string DeleteActorRoleRating { get; set; } + public string GetAllActorRoleTypes { get; set; } + public string GetActorRoleType { get; set; } + public string PostActorRoleType { get; set; } + public string DeleteActorRoleType { get; set; } + public string GetCreatorRole { get; set; } + public string PutCreatorRole { get; set; } + public string DeleteCreatorRole { get; set; } + public string GetCreatorRoleRating { get; set; } + public string GetCreatorRoleRatingByUser { get; set; } + public string PutCreatorRoleRating { get; set; } + public string DeleteCreatorRoleRating { get; set; } + public string GetAllCreatorRoleTypes { get; set; } + public string GetCreatorRoleType { get; set; } + public string PostCreatorRoleType { get; set; } + public string DeleteCreatorRoleType { get; set; } +} \ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.Utility/WatchIt.Website.Services.Utility.Configuration/Model/Style.cs b/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.Utility/WatchIt.Website.Services.Utility.Configuration/Model/Style.cs new file mode 100644 index 0000000..00abcbd --- /dev/null +++ b/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.Utility/WatchIt.Website.Services.Utility.Configuration/Model/Style.cs @@ -0,0 +1,6 @@ +namespace WatchIt.Website.Services.Utility.Configuration.Model; + +public class Style +{ + public int DefaultPanelPadding { get; set; } +} \ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.WebAPI/WatchIt.Website.Services.WebAPI.Genders/GendersWebAPIService.cs b/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.WebAPI/WatchIt.Website.Services.WebAPI.Genders/GendersWebAPIService.cs new file mode 100644 index 0000000..1976795 --- /dev/null +++ b/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.WebAPI/WatchIt.Website.Services.WebAPI.Genders/GendersWebAPIService.cs @@ -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>? 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? 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? successAction = null, Action>? 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 +} \ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.WebAPI/WatchIt.Website.Services.WebAPI.Genders/IGendersWebAPIService.cs b/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.WebAPI/WatchIt.Website.Services.WebAPI.Genders/IGendersWebAPIService.cs new file mode 100644 index 0000000..393b0fe --- /dev/null +++ b/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.WebAPI/WatchIt.Website.Services.WebAPI.Genders/IGendersWebAPIService.cs @@ -0,0 +1,11 @@ +using WatchIt.Common.Model.Genders; + +namespace WatchIt.Website.Services.WebAPI.Genders; + +public interface IGendersWebAPIService +{ + Task GetAllGenders(GenderQueryParameters? query = null, Action>? successAction = null); + Task GetGender(long id, Action? successAction = null, Action? notFoundAction = null); + Task PostGender(GenderRequest data, Action? successAction = null, Action>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null); + Task DeleteGender(long id, Action? successAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null); +} \ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.WebAPI/WatchIt.Website.Services.WebAPI.Genders/WatchIt.Website.Services.WebAPI.Genders.csproj b/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.WebAPI/WatchIt.Website.Services.WebAPI.Genders/WatchIt.Website.Services.WebAPI.Genders.csproj new file mode 100644 index 0000000..abf3359 --- /dev/null +++ b/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.WebAPI/WatchIt.Website.Services.WebAPI.Genders/WatchIt.Website.Services.WebAPI.Genders.csproj @@ -0,0 +1,14 @@ + + + + net8.0 + enable + enable + + + + + + + + diff --git a/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.WebAPI/WatchIt.Website.Services.WebAPI.Media/IMediaWebAPIService.cs b/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.WebAPI/WatchIt.Website.Services.WebAPI.Media/IMediaWebAPIService.cs index 9e5c9b4..7f80fa0 100644 --- a/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.WebAPI/WatchIt.Website.Services.WebAPI.Media/IMediaWebAPIService.cs +++ b/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.WebAPI/WatchIt.Website.Services.WebAPI.Media/IMediaWebAPIService.cs @@ -2,11 +2,13 @@ using WatchIt.Common.Model.Media; using WatchIt.Common.Model.Photos; using WatchIt.Common.Model.Rating; +using WatchIt.Common.Model.Roles; namespace WatchIt.Website.Services.WebAPI.Media; public interface IMediaWebAPIService { + Task GetAllMedia(MediaQueryParameters? query = null, Action>? successAction = null); Task GetMedia(long mediaId, Action? successAction = null, Action? notFoundAction = null); Task GetMediaGenres(long mediaId, Action>? successAction = null, Action? notFoundAction = null); @@ -27,4 +29,9 @@ public interface IMediaWebAPIService Task GetMediaPhotos(long mediaId, PhotoQueryParameters? query = null, Action>? successAction = null, Action? notFoundAction = null); Task GetMediaPhotoRandomBackground(long mediaId, Action? successAction = null, Action? notFoundAction = null); Task PostMediaPhoto(long mediaId, MediaPhotoRequest data, Action? successAction = null, Action>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null, Action? notFoundAction = null); + + Task GetMediaAllActorRoles(long id, ActorRoleMediaQueryParameters? query = null, Action>? successAction = null); + Task PostMediaActorRole(long id, ActorRoleMediaRequest data, Action? successAction = null, Action>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null); + Task GetMediaAllCreatorRoles(long id, CreatorRoleMediaQueryParameters? query = null, Action>? successAction = null); + Task PostMediaCreatorRole(long id, CreatorRoleMediaRequest data, Action? successAction = null, Action>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null); } \ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.WebAPI/WatchIt.Website.Services.WebAPI.Media/MediaWebAPIService.cs b/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.WebAPI/WatchIt.Website.Services.WebAPI.Media/MediaWebAPIService.cs index f95ae52..4fecf3b 100644 --- a/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.WebAPI/WatchIt.Website.Services.WebAPI.Media/MediaWebAPIService.cs +++ b/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.WebAPI/WatchIt.Website.Services.WebAPI.Media/MediaWebAPIService.cs @@ -2,6 +2,7 @@ using WatchIt.Common.Model.Media; using WatchIt.Common.Model.Photos; using WatchIt.Common.Model.Rating; +using WatchIt.Common.Model.Roles; using WatchIt.Common.Services.HttpClient; using WatchIt.Website.Services.Utility.Configuration; using WatchIt.Website.Services.Utility.Configuration.Model; @@ -34,6 +35,18 @@ public class MediaWebAPIService : BaseWebAPIService, IMediaWebAPIService #region Main + public async Task GetAllMedia(MediaQueryParameters? query = null, Action>? successAction = null) + { + string url = GetUrl(EndpointsConfiguration.Media.GetAllMedia); + + HttpRequest request = new HttpRequest(HttpMethodType.Get, url); + request.Query = query; + + HttpResponse response = await _httpClientService.SendRequestAsync(request); + response.RegisterActionFor2XXSuccess(successAction) + .ExecuteAction(); + } + public async Task GetMedia(long mediaId, Action? successAction = null, Action? notFoundAction = null) { string url = GetUrl(EndpointsConfiguration.Media.GetMedia, mediaId); @@ -258,6 +271,64 @@ public class MediaWebAPIService : BaseWebAPIService, IMediaWebAPIService #endregion + #region Roles + + public async Task GetMediaAllActorRoles(long id, ActorRoleMediaQueryParameters? query = null, Action>? successAction = null) + { + string url = GetUrl(EndpointsConfiguration.Media.GetMediaAllActorRoles, id); + + HttpRequest request = new HttpRequest(HttpMethodType.Get, url); + request.Query = query; + + HttpResponse response = await _httpClientService.SendRequestAsync(request); + response.RegisterActionFor2XXSuccess(successAction) + .ExecuteAction(); + } + + public async Task PostMediaActorRole(long id, ActorRoleMediaRequest data, Action? successAction = null, Action>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null) + { + string url = GetUrl(EndpointsConfiguration.Media.PostMediaActorRole, id); + + 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 GetMediaAllCreatorRoles(long id, CreatorRoleMediaQueryParameters? query = null, Action>? successAction = null) + { + string url = GetUrl(EndpointsConfiguration.Media.GetMediaAllCreatorRoles, id); + + HttpRequest request = new HttpRequest(HttpMethodType.Get, url); + request.Query = query; + + HttpResponse response = await _httpClientService.SendRequestAsync(request); + response.RegisterActionFor2XXSuccess(successAction) + .ExecuteAction(); + } + + public async Task PostMediaCreatorRole(long id, CreatorRoleMediaRequest data, Action? successAction = null, Action>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null) + { + string url = GetUrl(EndpointsConfiguration.Media.PostMediaCreatorRole, id); + + 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(); + } + + #endregion + #endregion diff --git a/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.WebAPI/WatchIt.Website.Services.WebAPI.Persons/IPersonsWebAPIService.cs b/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.WebAPI/WatchIt.Website.Services.WebAPI.Persons/IPersonsWebAPIService.cs new file mode 100644 index 0000000..071ed25 --- /dev/null +++ b/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.WebAPI/WatchIt.Website.Services.WebAPI.Persons/IPersonsWebAPIService.cs @@ -0,0 +1,29 @@ +using WatchIt.Common.Model.Persons; +using WatchIt.Common.Model.Rating; +using WatchIt.Common.Model.Roles; + +namespace WatchIt.Website.Services.WebAPI.Persons; + +public interface IPersonsWebAPIService +{ + Task GetAllPersons(PersonQueryParameters? query = null, Action>? successAction = null); + Task GetPerson(long id, Action? successAction = null, Action? notFoundAction = null); + Task PostPerson(PersonRequest data, Action? successAction = null, Action>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null); + Task PutPerson(long id, PersonRequest data, Action? successAction = null, Action>? badRequestAction = 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>? successAction = null, Action>? badRequestAction = null); + Task PostPersonView(long personId, Action? successAction = null, Action? notFoundAction = null); + + Task GetPersonPhoto(long id, Action? successAction = null, Action>? badRequestAction = null, Action? notFoundAction = null); + Task PutPersonPhoto(long id, PersonPhotoRequest data, Action? successAction = null, Action>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null); + Task DeletePersonPhoto(long id, Action? successAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null); + + Task GetPersonAllActorRoles(long id, ActorRolePersonQueryParameters? query = null, Action>? successAction = null); + Task PostPersonActorRole(long id, ActorRolePersonRequest data, Action? successAction = null, Action>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null); + Task GetPersonAllCreatorRoles(long id, CreatorRolePersonQueryParameters? query = null, Action>? successAction = null); + Task PostPersonCreatorRole(long id, CreatorRolePersonRequest data, Action? successAction = null, Action>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null); + + Task GetPersonGlobalRating(long id, Action? successAction = null, Action? notFoundAction = null); + Task GetPersonUserRating(long id, long userId, Action? successAction = null, Action? notFoundAction = null); +} \ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.WebAPI/WatchIt.Website.Services.WebAPI.Persons/PersonsWebAPIService.cs b/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.WebAPI/WatchIt.Website.Services.WebAPI.Persons/PersonsWebAPIService.cs new file mode 100644 index 0000000..a38a6f0 --- /dev/null +++ b/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.WebAPI/WatchIt.Website.Services.WebAPI.Persons/PersonsWebAPIService.cs @@ -0,0 +1,299 @@ +using System.Text; +using Microsoft.AspNetCore.Components; +using Microsoft.Extensions.Primitives; +using WatchIt.Common.Model.Persons; +using WatchIt.Common.Model.Rating; +using WatchIt.Common.Model.Roles; +using WatchIt.Common.Services.HttpClient; +using WatchIt.Website.Services.Utility.Configuration; +using WatchIt.Website.Services.WebAPI.Common; + +namespace WatchIt.Website.Services.WebAPI.Persons; + +public class PersonsWebAPIService : BaseWebAPIService, IPersonsWebAPIService +{ + #region SERVICES + + private IHttpClientService _httpClientService; + private IConfigurationService _configurationService; + + #endregion + + + + #region CONSTRUCTORS + + public PersonsWebAPIService(IHttpClientService httpClientService, IConfigurationService configurationService) : base(configurationService) + { + _httpClientService = httpClientService; + _configurationService = configurationService; + } + + #endregion + + + + #region PUBLIC METHODS + + #region Main + + public async Task GetAllPersons(PersonQueryParameters? query = null, Action>? successAction = null) + { + string url = GetUrl(EndpointsConfiguration.Persons.GetAllPersons); + + HttpRequest request = new HttpRequest(HttpMethodType.Get, url); + request.Query = query; + + HttpResponse response = await _httpClientService.SendRequestAsync(request); + response.RegisterActionFor2XXSuccess(successAction) + .ExecuteAction(); + } + + public async Task GetPerson(long id, Action? successAction = null, Action? notFoundAction = null) + { + string url = GetUrl(EndpointsConfiguration.Persons.GetPerson, id); + + HttpRequest request = new HttpRequest(HttpMethodType.Get, url); + + HttpResponse response = await _httpClientService.SendRequestAsync(request); + response.RegisterActionFor2XXSuccess(successAction) + .RegisterActionFor404NotFound(notFoundAction) + .ExecuteAction(); + } + + public async Task PostPerson(PersonRequest data, Action? successAction = null, Action>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null) + { + string url = GetUrl(EndpointsConfiguration.Persons.PostPerson); + + 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 PutPerson(long id, PersonRequest data, Action? successAction = null, Action>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null) + { + string url = GetUrl(EndpointsConfiguration.Persons.PutPerson, id); + + HttpRequest request = new HttpRequest(HttpMethodType.Put, url); + request.Body = data; + + HttpResponse response = await _httpClientService.SendRequestAsync(request); + response.RegisterActionFor2XXSuccess(successAction) + .RegisterActionFor400BadRequest(badRequestAction) + .RegisterActionFor401Unauthorized(unauthorizedAction) + .RegisterActionFor403Forbidden(forbiddenAction) + .ExecuteAction(); + } + + public async Task DeletePerson(long id, Action? successAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null) + { + string url = GetUrl(EndpointsConfiguration.Persons.DeletePerson, id); + + HttpRequest request = new HttpRequest(HttpMethodType.Delete, url); + + HttpResponse response = await _httpClientService.SendRequestAsync(request); + response.RegisterActionFor2XXSuccess(successAction) + .RegisterActionFor401Unauthorized(unauthorizedAction) + .RegisterActionFor403Forbidden(forbiddenAction) + .ExecuteAction(); + } + + #endregion + + #region View count + + public async Task GetPersonsViewRank(int? first = null, int? days = null, Action>? successAction = null, Action>? badRequestAction = null) + { + string url = GetUrl(EndpointsConfiguration.Persons.GetPersonsViewRank); + if (first.HasValue || days.HasValue) + { + StringBuilder urlBuilder = new StringBuilder(url); + urlBuilder.Append('?'); + bool firstParameter = true; + if (first.HasValue) + { + urlBuilder.Append($"first={first.Value}"); + firstParameter = false; + } + if (days.HasValue) + { + if (!firstParameter) + { + urlBuilder.Append('&'); + } + urlBuilder.Append($"days={days.Value}"); + } + url = urlBuilder.ToString(); + } + + HttpRequest request = new HttpRequest(HttpMethodType.Get, url); + + HttpResponse response = await _httpClientService.SendRequestAsync(request); + response.RegisterActionFor2XXSuccess(successAction) + .RegisterActionFor400BadRequest(badRequestAction) + .ExecuteAction(); + } + + public async Task PostPersonView(long personId, Action? successAction = null, Action? notFoundAction = null) + { + string url = GetUrl(EndpointsConfiguration.Persons.PostPersonsView, personId); + + HttpRequest request = new HttpRequest(HttpMethodType.Post, url); + + HttpResponse response = await _httpClientService.SendRequestAsync(request); + response.RegisterActionFor2XXSuccess(successAction) + .RegisterActionFor404NotFound(notFoundAction) + .ExecuteAction(); + } + + #endregion + + #region Photo + + public async Task GetPersonPhoto(long id, Action? successAction = null, Action>? 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? successAction = null, Action>? 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 + + #region Roles + + public async Task GetPersonAllActorRoles(long id, ActorRolePersonQueryParameters? query = null, Action>? successAction = null) + { + string url = GetUrl(EndpointsConfiguration.Persons.GetPersonAllActorRoles, id); + + HttpRequest request = new HttpRequest(HttpMethodType.Get, url); + request.Query = query; + + HttpResponse response = await _httpClientService.SendRequestAsync(request); + response.RegisterActionFor2XXSuccess(successAction) + .ExecuteAction(); + } + + public async Task PostPersonActorRole(long id, ActorRolePersonRequest data, Action? successAction = null, Action>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null) + { + string url = GetUrl(EndpointsConfiguration.Persons.PostPersonActorRole, id); + + 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 GetPersonAllCreatorRoles(long id, CreatorRolePersonQueryParameters? query = null, Action>? successAction = null) + { + string url = GetUrl(EndpointsConfiguration.Persons.GetPersonAllCreatorRoles, id); + + HttpRequest request = new HttpRequest(HttpMethodType.Get, url); + request.Query = query; + + HttpResponse response = await _httpClientService.SendRequestAsync(request); + response.RegisterActionFor2XXSuccess(successAction) + .ExecuteAction(); + } + + public async Task PostPersonCreatorRole(long id, CreatorRolePersonRequest data, Action? successAction = null, Action>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null) + { + string url = GetUrl(EndpointsConfiguration.Persons.PostPersonCreatorRole, id); + + 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(); + } + + #endregion + + #region Rating + + public async Task GetPersonGlobalRating(long id, Action? successAction = null, Action? notFoundAction = null) + { + string url = GetUrl(EndpointsConfiguration.Persons.GetPersonGlobalRating, id); + + HttpRequest request = new HttpRequest(HttpMethodType.Get, url); + + HttpResponse response = await _httpClientService.SendRequestAsync(request); + response.RegisterActionFor2XXSuccess(successAction) + .RegisterActionFor404NotFound(notFoundAction) + .ExecuteAction(); + } + + public async Task GetPersonUserRating(long id, long userId, Action? successAction = null, Action? notFoundAction = null) + { + string url = GetUrl(EndpointsConfiguration.Persons.GetPersonUserRating, id, userId); + + HttpRequest request = new HttpRequest(HttpMethodType.Get, url); + + HttpResponse response = await _httpClientService.SendRequestAsync(request); + response.RegisterActionFor2XXSuccess(successAction) + .RegisterActionFor404NotFound(notFoundAction) + .ExecuteAction(); + } + + #endregion + + #endregion + + + + #region PRIVATE METHODS + + protected override string GetServiceBase() => EndpointsConfiguration.Persons.Base; + + #endregion +} \ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.WebAPI/WatchIt.Website.Services.WebAPI.Persons/WatchIt.Website.Services.WebAPI.Persons.csproj b/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.WebAPI/WatchIt.Website.Services.WebAPI.Persons/WatchIt.Website.Services.WebAPI.Persons.csproj new file mode 100644 index 0000000..abf3359 --- /dev/null +++ b/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.WebAPI/WatchIt.Website.Services.WebAPI.Persons/WatchIt.Website.Services.WebAPI.Persons.csproj @@ -0,0 +1,14 @@ + + + + net8.0 + enable + enable + + + + + + + + diff --git a/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.WebAPI/WatchIt.Website.Services.WebAPI.Roles/IRolesWebAPIService.cs b/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.WebAPI/WatchIt.Website.Services.WebAPI.Roles/IRolesWebAPIService.cs new file mode 100644 index 0000000..b270d98 --- /dev/null +++ b/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.WebAPI/WatchIt.Website.Services.WebAPI.Roles/IRolesWebAPIService.cs @@ -0,0 +1,31 @@ +using WatchIt.Common.Model.Rating; +using WatchIt.Common.Model.Roles; + +namespace WatchIt.Website.Services.WebAPI.Roles; + +public interface IRolesWebAPIService +{ + Task GetActorRole(Guid id, Action? successAction = null, Action? notFoundAction = null); + Task PutActorRole(Guid id, ActorRoleUniversalRequest data, Action? successAction = null, Action>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null, Action? notFoundAction = null); + Task DeleteActorRole(Guid id, Action? successAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null); + Task GetActorRoleRating(Guid id, Action? successAction = null, Action? notFoundAction = null); + Task GetActorRoleRatingByUser(Guid id, long userId, Action? successAction = null, Action? notFoundAction = null); + Task PutActorRoleRating(Guid id, RatingRequest body, Action? successAction = null, Action>? badRequestAction = null, Action? unauthorizedAction = null, Action? notFoundAction = null); + Task DeleteActorRoleRating(Guid id, Action? successAction = null, Action? unauthorizedAction = null); + Task GetAllActorRoleTypes(RoleTypeQueryParameters? query = null, Action>? successAction = null); + Task GetActorRoleType(long typeId, Action? successAction = null, Action? notFoundAction = null); + Task PostActorRoleType(RoleTypeRequest data, Action? successAction = null, Action>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null); + Task DeleteActorRoleType(long typeId, Action? successAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null); + + Task GetCreatorRole(Guid id, Action? successAction = null, Action? notFoundAction = null); + Task PutCreatorRole(Guid id, CreatorRoleUniversalRequest data, Action? successAction = null, Action>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null, Action? notFoundAction = null); + Task DeleteCreatorRole(Guid id, Action? successAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null); + Task GetCreatorRoleRating(Guid id, Action? successAction = null, Action? notFoundAction = null); + Task GetCreatorRoleRatingByUser(Guid id, long userId, Action? successAction = null, Action? notFoundAction = null); + Task PutCreatorRoleRating(Guid id, RatingRequest body, Action? successAction = null, Action>? badRequestAction = null, Action? unauthorizedAction = null, Action? notFoundAction = null); + Task DeleteCreatorRoleRating(Guid id, Action? successAction = null, Action? unauthorizedAction = null); + Task GetAllCreatorRoleTypes(RoleTypeQueryParameters? query = null, Action>? successAction = null); + Task GetCreatorRoleType(long typeId, Action? successAction = null, Action? notFoundAction = null); + Task PostCreatorRoleType(RoleTypeRequest data, Action? successAction = null, Action>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null); + Task DeleteCreatorRoleType(long typeId, Action? successAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null); +} \ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.WebAPI/WatchIt.Website.Services.WebAPI.Roles/RolesWebAPIService.cs b/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.WebAPI/WatchIt.Website.Services.WebAPI.Roles/RolesWebAPIService.cs new file mode 100644 index 0000000..09b0418 --- /dev/null +++ b/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.WebAPI/WatchIt.Website.Services.WebAPI.Roles/RolesWebAPIService.cs @@ -0,0 +1,341 @@ +using WatchIt.Common.Model.Rating; +using WatchIt.Common.Model.Roles; +using WatchIt.Common.Services.HttpClient; +using WatchIt.Website.Services.Utility.Configuration; +using WatchIt.Website.Services.WebAPI.Common; + +namespace WatchIt.Website.Services.WebAPI.Roles; + +public class RolesWebAPIService : BaseWebAPIService, IRolesWebAPIService +{ + #region SERVICES + + private IHttpClientService _httpClientService; + + #endregion + + + + #region CONSTRUCTORS + + public RolesWebAPIService(IHttpClientService httpClientService, IConfigurationService configurationService) : base(configurationService) + { + _httpClientService = httpClientService; + } + + #endregion + + + + #region PUBLIC METHODS + + #region Actor + + public async Task GetActorRole(Guid id, Action? successAction = null, Action? notFoundAction = null) + { + string url = GetUrl(EndpointsConfiguration.Roles.GetActorRole, id); + + HttpRequest request = new HttpRequest(HttpMethodType.Get, url); + + HttpResponse response = await _httpClientService.SendRequestAsync(request); + response.RegisterActionFor2XXSuccess(successAction) + .RegisterActionFor404NotFound(notFoundAction) + .ExecuteAction(); + } + + public async Task PutActorRole(Guid id, ActorRoleUniversalRequest data, Action? successAction = null, Action>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null, Action? notFoundAction = null) + { + string url = GetUrl(EndpointsConfiguration.Roles.PutActorRole, id); + + HttpRequest request = new HttpRequest(HttpMethodType.Put, url); + request.Body = data; + + HttpResponse response = await _httpClientService.SendRequestAsync(request); + response.RegisterActionFor2XXSuccess(successAction) + .RegisterActionFor400BadRequest(badRequestAction) + .RegisterActionFor401Unauthorized(unauthorizedAction) + .RegisterActionFor403Forbidden(forbiddenAction) + .RegisterActionFor404NotFound(notFoundAction) + .ExecuteAction(); + } + + public async Task DeleteActorRole(Guid id, Action? successAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null) + { + string url = GetUrl(EndpointsConfiguration.Roles.DeleteActorRole, id); + + HttpRequest request = new HttpRequest(HttpMethodType.Delete, url); + + HttpResponse response = await _httpClientService.SendRequestAsync(request); + response.RegisterActionFor2XXSuccess(successAction) + .RegisterActionFor401Unauthorized(unauthorizedAction) + .RegisterActionFor403Forbidden(forbiddenAction) + .ExecuteAction(); + } + + public async Task GetActorRoleRating(Guid id, Action? successAction = null, Action? notFoundAction = null) + { + string url = GetUrl(EndpointsConfiguration.Roles.GetActorRoleRating, id); + + HttpRequest request = new HttpRequest(HttpMethodType.Get, url); + + HttpResponse response = await _httpClientService.SendRequestAsync(request); + response.RegisterActionFor2XXSuccess(successAction) + .RegisterActionFor404NotFound(notFoundAction) + .ExecuteAction(); + } + + public async Task GetActorRoleRatingByUser(Guid id, long userId, Action? successAction = null, Action? notFoundAction = null) + { + string url = GetUrl(EndpointsConfiguration.Roles.GetActorRoleRatingByUser, id, userId); + + HttpRequest request = new HttpRequest(HttpMethodType.Get, url); + + HttpResponse response = await _httpClientService.SendRequestAsync(request); + response.RegisterActionFor2XXSuccess(successAction) + .RegisterActionFor404NotFound(notFoundAction) + .ExecuteAction(); + } + + public async Task PutActorRoleRating(Guid id, RatingRequest body, Action? successAction = null, Action>? badRequestAction = null, Action? unauthorizedAction = null, Action? notFoundAction = null) + { + string url = GetUrl(EndpointsConfiguration.Roles.PutActorRoleRating, id); + + HttpRequest request = new HttpRequest(HttpMethodType.Put, url) + { + Body = body + }; + + HttpResponse response = await _httpClientService.SendRequestAsync(request); + response.RegisterActionFor2XXSuccess(successAction) + .RegisterActionFor400BadRequest(badRequestAction) + .RegisterActionFor401Unauthorized(unauthorizedAction) + .RegisterActionFor404NotFound(notFoundAction) + .ExecuteAction(); + } + + public async Task DeleteActorRoleRating(Guid id, Action? successAction = null, Action? unauthorizedAction = null) + { + string url = GetUrl(EndpointsConfiguration.Roles.DeleteActorRoleRating, id); + + HttpRequest request = new HttpRequest(HttpMethodType.Delete, url); + + HttpResponse response = await _httpClientService.SendRequestAsync(request); + response.RegisterActionFor2XXSuccess(successAction) + .RegisterActionFor401Unauthorized(unauthorizedAction) + .ExecuteAction(); + } + + public async Task GetAllActorRoleTypes(RoleTypeQueryParameters? query = null, Action>? successAction = null) + { + string url = GetUrl(EndpointsConfiguration.Roles.GetAllActorRoleTypes); + + HttpRequest request = new HttpRequest(HttpMethodType.Get, url); + request.Query = query; + + HttpResponse response = await _httpClientService.SendRequestAsync(request); + response.RegisterActionFor2XXSuccess(successAction) + .ExecuteAction(); + } + + public async Task GetActorRoleType(long typeId, Action? successAction = null, Action? notFoundAction = null) + { + string url = GetUrl(EndpointsConfiguration.Roles.GetActorRoleType, typeId); + + HttpRequest request = new HttpRequest(HttpMethodType.Get, url); + + HttpResponse response = await _httpClientService.SendRequestAsync(request); + response.RegisterActionFor2XXSuccess(successAction) + .RegisterActionFor404NotFound(notFoundAction) + .ExecuteAction(); + } + + public async Task PostActorRoleType(RoleTypeRequest data, Action? successAction = null, Action>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null) + { + string url = GetUrl(EndpointsConfiguration.Roles.PostActorRoleType); + + 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 DeleteActorRoleType(long typeId, Action? successAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null) + { + string url = GetUrl(EndpointsConfiguration.Roles.DeleteActorRoleType, typeId); + + HttpRequest request = new HttpRequest(HttpMethodType.Delete, url); + + HttpResponse response = await _httpClientService.SendRequestAsync(request); + response.RegisterActionFor2XXSuccess(successAction) + .RegisterActionFor401Unauthorized(unauthorizedAction) + .RegisterActionFor403Forbidden(forbiddenAction) + .ExecuteAction(); + } + + #endregion + + #region Creator + + public async Task GetCreatorRole(Guid id, Action? successAction = null, Action? notFoundAction = null) + { + string url = GetUrl(EndpointsConfiguration.Roles.GetCreatorRole, id); + + HttpRequest request = new HttpRequest(HttpMethodType.Get, url); + + HttpResponse response = await _httpClientService.SendRequestAsync(request); + response.RegisterActionFor2XXSuccess(successAction) + .RegisterActionFor404NotFound(notFoundAction) + .ExecuteAction(); + } + + public async Task PutCreatorRole(Guid id, CreatorRoleUniversalRequest data, Action? successAction = null, Action>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null, Action? notFoundAction = null) + { + string url = GetUrl(EndpointsConfiguration.Roles.PutCreatorRole, id); + + HttpRequest request = new HttpRequest(HttpMethodType.Put, url); + request.Body = data; + + HttpResponse response = await _httpClientService.SendRequestAsync(request); + response.RegisterActionFor2XXSuccess(successAction) + .RegisterActionFor400BadRequest(badRequestAction) + .RegisterActionFor401Unauthorized(unauthorizedAction) + .RegisterActionFor403Forbidden(forbiddenAction) + .RegisterActionFor404NotFound(notFoundAction) + .ExecuteAction(); + } + + public async Task DeleteCreatorRole(Guid id, Action? successAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null) + { + string url = GetUrl(EndpointsConfiguration.Roles.DeleteCreatorRole, id); + + HttpRequest request = new HttpRequest(HttpMethodType.Delete, url); + + HttpResponse response = await _httpClientService.SendRequestAsync(request); + response.RegisterActionFor2XXSuccess(successAction) + .RegisterActionFor401Unauthorized(unauthorizedAction) + .RegisterActionFor403Forbidden(forbiddenAction) + .ExecuteAction(); + } + + public async Task GetCreatorRoleRating(Guid id, Action? successAction = null, Action? notFoundAction = null) + { + string url = GetUrl(EndpointsConfiguration.Roles.GetCreatorRoleRating, id); + + HttpRequest request = new HttpRequest(HttpMethodType.Get, url); + + HttpResponse response = await _httpClientService.SendRequestAsync(request); + response.RegisterActionFor2XXSuccess(successAction) + .RegisterActionFor404NotFound(notFoundAction) + .ExecuteAction(); + } + + public async Task GetCreatorRoleRatingByUser(Guid id, long userId, Action? successAction = null, Action? notFoundAction = null) + { + string url = GetUrl(EndpointsConfiguration.Roles.GetCreatorRoleRatingByUser, id, userId); + + HttpRequest request = new HttpRequest(HttpMethodType.Get, url); + + HttpResponse response = await _httpClientService.SendRequestAsync(request); + response.RegisterActionFor2XXSuccess(successAction) + .RegisterActionFor404NotFound(notFoundAction) + .ExecuteAction(); + } + + public async Task PutCreatorRoleRating(Guid id, RatingRequest body, Action? successAction = null, Action>? badRequestAction = null, Action? unauthorizedAction = null, Action? notFoundAction = null) + { + string url = GetUrl(EndpointsConfiguration.Roles.PutCreatorRoleRating, id); + + HttpRequest request = new HttpRequest(HttpMethodType.Put, url) + { + Body = body + }; + + HttpResponse response = await _httpClientService.SendRequestAsync(request); + response.RegisterActionFor2XXSuccess(successAction) + .RegisterActionFor400BadRequest(badRequestAction) + .RegisterActionFor401Unauthorized(unauthorizedAction) + .RegisterActionFor404NotFound(notFoundAction) + .ExecuteAction(); + } + + public async Task DeleteCreatorRoleRating(Guid id, Action? successAction = null, Action? unauthorizedAction = null) + { + string url = GetUrl(EndpointsConfiguration.Roles.DeleteCreatorRoleRating, id); + + HttpRequest request = new HttpRequest(HttpMethodType.Delete, url); + + HttpResponse response = await _httpClientService.SendRequestAsync(request); + response.RegisterActionFor2XXSuccess(successAction) + .RegisterActionFor401Unauthorized(unauthorizedAction) + .ExecuteAction(); + } + + public async Task GetAllCreatorRoleTypes(RoleTypeQueryParameters? query = null, Action>? successAction = null) + { + string url = GetUrl(EndpointsConfiguration.Roles.GetAllCreatorRoleTypes); + + HttpRequest request = new HttpRequest(HttpMethodType.Get, url); + request.Query = query; + + HttpResponse response = await _httpClientService.SendRequestAsync(request); + response.RegisterActionFor2XXSuccess(successAction) + .ExecuteAction(); + } + + public async Task GetCreatorRoleType(long typeId, Action? successAction = null, Action? notFoundAction = null) + { + string url = GetUrl(EndpointsConfiguration.Roles.GetCreatorRoleType, typeId); + + HttpRequest request = new HttpRequest(HttpMethodType.Get, url); + + HttpResponse response = await _httpClientService.SendRequestAsync(request); + response.RegisterActionFor2XXSuccess(successAction) + .RegisterActionFor404NotFound(notFoundAction) + .ExecuteAction(); + } + + public async Task PostCreatorRoleType(RoleTypeRequest data, Action? successAction = null, Action>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null) + { + string url = GetUrl(EndpointsConfiguration.Roles.PostCreatorRoleType); + + 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 DeleteCreatorRoleType(long typeId, Action? successAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null) + { + string url = GetUrl(EndpointsConfiguration.Roles.DeleteCreatorRoleType, typeId); + + 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.Roles.Base; + + #endregion +} \ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.WebAPI/WatchIt.Website.Services.WebAPI.Roles/WatchIt.Website.Services.WebAPI.Roles.csproj b/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.WebAPI/WatchIt.Website.Services.WebAPI.Roles/WatchIt.Website.Services.WebAPI.Roles.csproj new file mode 100644 index 0000000..abf3359 --- /dev/null +++ b/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.WebAPI/WatchIt.Website.Services.WebAPI.Roles/WatchIt.Website.Services.WebAPI.Roles.csproj @@ -0,0 +1,14 @@ + + + + net8.0 + enable + enable + + + + + + + + diff --git a/WatchIt.Website/WatchIt.Website/App.razor b/WatchIt.Website/WatchIt.Website/App.razor index fb9b08f..e5cba46 100644 --- a/WatchIt.Website/WatchIt.Website/App.razor +++ b/WatchIt.Website/WatchIt.Website/App.razor @@ -9,9 +9,11 @@ - - - + + + + + diff --git a/WatchIt.Website/WatchIt.Website/Components/Common/Panels/ErrorPanelComponent.razor b/WatchIt.Website/WatchIt.Website/Components/Common/Panels/ErrorPanelComponent.razor new file mode 100644 index 0000000..b611147 --- /dev/null +++ b/WatchIt.Website/WatchIt.Website/Components/Common/Panels/ErrorPanelComponent.razor @@ -0,0 +1,16 @@ +
+
+
+
⚠︎
+
+
+

An error occured while loading a page

+
+ @if (!string.IsNullOrWhiteSpace(ErrorMessage)) + { +
+

@ErrorMessage

+
+ } +
+
\ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Components/ErrorComponent.razor.cs b/WatchIt.Website/WatchIt.Website/Components/Common/Panels/ErrorPanelComponent.razor.cs similarity index 57% rename from WatchIt.Website/WatchIt.Website/Components/ErrorComponent.razor.cs rename to WatchIt.Website/WatchIt.Website/Components/Common/Panels/ErrorPanelComponent.razor.cs index 20cde5f..4a860db 100644 --- a/WatchIt.Website/WatchIt.Website/Components/ErrorComponent.razor.cs +++ b/WatchIt.Website/WatchIt.Website/Components/Common/Panels/ErrorPanelComponent.razor.cs @@ -1,8 +1,8 @@ using Microsoft.AspNetCore.Components; -namespace WatchIt.Website.Components; +namespace WatchIt.Website.Components.Common.Panels; -public partial class ErrorComponent : ComponentBase +public partial class ErrorPanelComponent : ComponentBase { #region PARAMETERS diff --git a/WatchIt.Website/WatchIt.Website/Components/ErrorComponent.razor.css b/WatchIt.Website/WatchIt.Website/Components/Common/Panels/ErrorPanelComponent.razor.css similarity index 100% rename from WatchIt.Website/WatchIt.Website/Components/ErrorComponent.razor.css rename to WatchIt.Website/WatchIt.Website/Components/Common/Panels/ErrorPanelComponent.razor.css diff --git a/WatchIt.Website/WatchIt.Website/Components/Common/Panels/ItemPageHeaderPanelComponent.razor b/WatchIt.Website/WatchIt.Website/Components/Common/Panels/ItemPageHeaderPanelComponent.razor new file mode 100644 index 0000000..689936a --- /dev/null +++ b/WatchIt.Website/WatchIt.Website/Components/Common/Panels/ItemPageHeaderPanelComponent.razor @@ -0,0 +1,22 @@ +
+
+
+ +
+
+
+

@(Name)

+
+ @if (!string.IsNullOrWhiteSpace(Subname)) + { + @(Subname) + } + @if (!string.IsNullOrWhiteSpace(Description)) + { + @(Description) + } +
+
+
+
+
\ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Components/Common/Panels/ItemPageHeaderPanelComponent.razor.cs b/WatchIt.Website/WatchIt.Website/Components/Common/Panels/ItemPageHeaderPanelComponent.razor.cs new file mode 100644 index 0000000..96e0fdd --- /dev/null +++ b/WatchIt.Website/WatchIt.Website/Components/Common/Panels/ItemPageHeaderPanelComponent.razor.cs @@ -0,0 +1,51 @@ +using Microsoft.AspNetCore.Components; +using WatchIt.Common.Model; + +namespace WatchIt.Website.Components.Common.Panels; + +public partial class ItemPageHeaderPanelComponent : ComponentBase +{ + #region PARAMETERS + + [Parameter] public required string Name { get; set; } + [Parameter] public string? Subname { get; set; } + [Parameter] public string? Description { get; set; } + + [Parameter] public required string PosterPlaceholder { get; set; } + [Parameter] public required Func, Task> GetPosterMethod { get; set; } + + #endregion + + + + #region FIELDS + + private Picture? _poster; + + #endregion + + + + #region PRIVATE METHODS + + protected override async Task OnAfterRenderAsync(bool firstRender) + { + if (firstRender) + { + List endTasks = new List(1); + + // STEP 0 + endTasks.AddRange( + [ + GetPosterMethod(data => _poster = data) + ]); + + // END + await Task.WhenAll(endTasks); + + StateHasChanged(); + } + } + + #endregion +} \ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Components/Common/Panels/ItemPageHeaderPanelComponent.razor.css b/WatchIt.Website/WatchIt.Website/Components/Common/Panels/ItemPageHeaderPanelComponent.razor.css new file mode 100644 index 0000000..8d33a8c --- /dev/null +++ b/WatchIt.Website/WatchIt.Website/Components/Common/Panels/ItemPageHeaderPanelComponent.razor.css @@ -0,0 +1,13 @@ +/* CLASSES */ + +.mt-grid { + margin-top: 9rem !important; +} + +.title-shadow { + text-shadow: 2px 2px 2px #000; +} + +.description-shadow { + text-shadow: 1px 1px 1px #000; +} \ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Components/Common/Panels/PictureEditorPanelComponent.razor b/WatchIt.Website/WatchIt.Website/Components/Common/Panels/PictureEditorPanelComponent.razor new file mode 100644 index 0000000..2264955 --- /dev/null +++ b/WatchIt.Website/WatchIt.Website/Components/Common/Panels/PictureEditorPanelComponent.razor @@ -0,0 +1,67 @@ +
+ @if (_loaded) + { +
+ + + @if (_pictureChanged || _pictureSaved is not null) + { +
+ @if (_pictureChanged) + { +
+
+
+ +
+
+ +
+
+
+ } + else if (_pictureSaved is not null) + { + + } +
+ } +
+ } + else + { +
+ +
+ } +
+ + + + \ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Components/Common/Panels/PictureEditorPanelComponent.razor.cs b/WatchIt.Website/WatchIt.Website/Components/Common/Panels/PictureEditorPanelComponent.razor.cs new file mode 100644 index 0000000..3bd56b1 --- /dev/null +++ b/WatchIt.Website/WatchIt.Website/Components/Common/Panels/PictureEditorPanelComponent.razor.cs @@ -0,0 +1,122 @@ +using Microsoft.AspNetCore.Components; +using Microsoft.AspNetCore.Components.Forms; +using WatchIt.Common.Model; + +namespace WatchIt.Website.Components.Common.Panels; + +public partial class PictureEditorPanelComponent : ComponentBase +{ + #region PARAMETERS + + [Parameter] public long? Id { get; set; } + [Parameter] public int ContentWidth { get; set; } = 300; + [Parameter] public required string PicturePlaceholder { get; set; } + [Parameter] public string Class { get; set; } = string.Empty; + [Parameter] public required Func, Task> PictureGetTask { get; set; } + [Parameter] public required Func, Task> PicturePutTask { get; set; } + [Parameter] public required Func 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 endTask = new List(); + + // 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 +} \ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Components/Common/Subcomponents/DisplayRatingComponent.razor b/WatchIt.Website/WatchIt.Website/Components/Common/Subcomponents/DisplayRatingComponent.razor new file mode 100644 index 0000000..da7a6c5 --- /dev/null +++ b/WatchIt.Website/WatchIt.Website/Components/Common/Subcomponents/DisplayRatingComponent.razor @@ -0,0 +1,51 @@ +@using Blazorise.Extensions +
+ @if (Rating is null || Rating.Count > 0 || EmptyMode == DisplayRatingComponentEmptyMode.DoubleDash) + { + + } +
+ @if (Rating is not null && Rating.Count > 0) + { + @($"{Math.Round(Rating.Average, 2)}/10") + @(Rating.Count) + } + else + { +
+ @if (Rating is null) + { +
/10
+ } + else + { + switch (EmptyMode) + { + case DisplayRatingComponentEmptyMode.NoRatings: @("no ratings"); break; + case DisplayRatingComponentEmptyMode.DoubleDash: @("--/10"); break; + } + } +
+ } +
+
+ + \ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Components/Common/Subcomponents/DisplayRatingComponent.razor.cs b/WatchIt.Website/WatchIt.Website/Components/Common/Subcomponents/DisplayRatingComponent.razor.cs new file mode 100644 index 0000000..8f6935e --- /dev/null +++ b/WatchIt.Website/WatchIt.Website/Components/Common/Subcomponents/DisplayRatingComponent.razor.cs @@ -0,0 +1,27 @@ +using Microsoft.AspNetCore.Components; +using WatchIt.Common.Model.Rating; + +namespace WatchIt.Website.Components.Common.Subcomponents; + +public partial class DisplayRatingComponent : ComponentBase +{ + #region PARAMETERS + + [Parameter] public RatingResponse? Rating { get; set; } + [Parameter] public DisplayRatingComponentEmptyMode EmptyMode { get; set; } = DisplayRatingComponentEmptyMode.NoRatings; + [Parameter] public double Scale { get; set; } = 1; + + #endregion + + + + #region ENUMS + + public enum DisplayRatingComponentEmptyMode + { + NoRatings, + DoubleDash, + } + + #endregion +} \ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Components/Common/Subcomponents/ListItemComponent.razor b/WatchIt.Website/WatchIt.Website/Components/Common/Subcomponents/ListItemComponent.razor new file mode 100644 index 0000000..42b9837 --- /dev/null +++ b/WatchIt.Website/WatchIt.Website/Components/Common/Subcomponents/ListItemComponent.razor @@ -0,0 +1,52 @@ +
+
+
+ + + +
+
+
+ +
+ +
+ 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... +
+ } + else + { + + } +
+
+ } +
+
+
+
+
\ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Components/Common/Subcomponents/ListItemComponent.razor.cs b/WatchIt.Website/WatchIt.Website/Components/Common/Subcomponents/ListItemComponent.razor.cs new file mode 100644 index 0000000..818f3ee --- /dev/null +++ b/WatchIt.Website/WatchIt.Website/Components/Common/Subcomponents/ListItemComponent.razor.cs @@ -0,0 +1,128 @@ +using Microsoft.AspNetCore.Components; +using WatchIt.Common.Model; +using WatchIt.Common.Model.Rating; +using WatchIt.Website.Services.Utility.Authentication; + +namespace WatchIt.Website.Components.Common.Subcomponents; + +public partial class ListItemComponent : ComponentBase +{ + #region SERVICES + + [Inject] private IAuthenticationService AuthenticationService { get; set; } = default!; + + #endregion + + + + #region PARAMETERS + + [Parameter] public required string Name { get; set; } + [Parameter] public string? AdditionalInfo { get; set; } + + [Parameter] public int NameSize { get; set; } = 25; + + [Parameter] public required string PosterPlaceholder { get; set; } + [Parameter] public int PosterHeight { get; set; } = 150; + [Parameter] public required Func, Task> PosterDownloadingTask { get; set; } + + [Parameter] public RatingResponse? GlobalRating { get; set; } + [Parameter] public required Func, Task> GetGlobalRatingMethod { get; set; } + [Parameter] public Func, Action, Task>? GetUserRatingMethod { get; set; } + [Parameter] public Func? PutRatingMethod { get; set; } + [Parameter] public Func? DeleteRatingMethod { get; set; } + [Parameter] public Action? OnRatingChanged { get; set; } + + [Parameter] public required string ItemUrl { get; set; } + + #endregion + + + + #region FIELDS + + private User? _user; + + private Picture? _poster; + + private int _userRating; + private bool _userRatingLoaded; + + #endregion + + + + #region PRIVATE METHODS + + protected override async Task OnAfterRenderAsync(bool firstRender) + { + if (firstRender) + { + List step1Tasks = new List(1); + List endTasks = new List(3); + + // STEP 0 + if (GetUserRatingMethod is not null) + { + step1Tasks.AddRange( + [ + Task.Run(async () => _user = await AuthenticationService.GetUserAsync()), + ]); + } + endTasks.AddRange( + [ + PosterDownloadingTask(data => _poster = data), + ]); + if (GlobalRating is null) + { + endTasks.AddRange( + [ + GetGlobalRatingMethod(data => GlobalRating = data), + ]); + } + + // STEP 1 + await Task.WhenAll(step1Tasks); + StateHasChanged(); + if (GetUserRatingMethod is not null && _user is not null) + { + endTasks.AddRange( + [ + GetUserRatingMethod(_user.Id, + data => + { + _userRating = data; + _userRatingLoaded = true; + }, + () => + { + _userRating = 0; + _userRatingLoaded = true; + } + ) + ]); + } + + await Task.WhenAll(endTasks); + + StateHasChanged(); + } + } + + private async Task RatingChanged() + { + if (_userRating == 0) + { + await DeleteRatingMethod!(); + } + else + { + await PutRatingMethod!(new RatingRequest((short)_userRating)); + } + + await GetGlobalRatingMethod(data => GlobalRating = data); + OnRatingChanged?.Invoke(); + } + + #endregion +} \ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Components/Common/Subcomponents/ListItemComponent.razor.css b/WatchIt.Website/WatchIt.Website/Components/Common/Subcomponents/ListItemComponent.razor.css new file mode 100644 index 0000000..7c26de1 --- /dev/null +++ b/WatchIt.Website/WatchIt.Website/Components/Common/Subcomponents/ListItemComponent.razor.css @@ -0,0 +1,10 @@ +/* IDS */ + +#ratingNameText { + font-size: 14px; + font-weight: bold; +} + +#ratingLoginInfoText { + font-size: 13px; +} \ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Components/Common/Subcomponents/LoadingButtonContentComponent.razor b/WatchIt.Website/WatchIt.Website/Components/Common/Subcomponents/LoadingButtonContentComponent.razor new file mode 100644 index 0000000..dcf57c2 --- /dev/null +++ b/WatchIt.Website/WatchIt.Website/Components/Common/Subcomponents/LoadingButtonContentComponent.razor @@ -0,0 +1,16 @@ +@if (IsLoading) +{ + + @LoadingContent +} +else +{ + if (ChildContent is null) + { + @Content + } + else + { + @(ChildContent) + } +} \ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Components/Common/Subcomponents/LoadingButtonContentComponent.razor.cs b/WatchIt.Website/WatchIt.Website/Components/Common/Subcomponents/LoadingButtonContentComponent.razor.cs new file mode 100644 index 0000000..716e615 --- /dev/null +++ b/WatchIt.Website/WatchIt.Website/Components/Common/Subcomponents/LoadingButtonContentComponent.razor.cs @@ -0,0 +1,15 @@ +using Microsoft.AspNetCore.Components; + +namespace WatchIt.Website.Components.Common.Subcomponents; + +public partial class LoadingButtonContentComponent : ComponentBase +{ + #region PARAMETERS + + [Parameter] public bool IsLoading { get; set; } + [Parameter] public string? LoadingContent { get; set; } + [Parameter] public string Content { get; set; } + [Parameter] public RenderFragment ChildContent { get; set; } + + #endregion +} \ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Components/LoadingComponent.razor b/WatchIt.Website/WatchIt.Website/Components/Common/Subcomponents/LoadingComponent.razor similarity index 52% rename from WatchIt.Website/WatchIt.Website/Components/LoadingComponent.razor rename to WatchIt.Website/WatchIt.Website/Components/Common/Subcomponents/LoadingComponent.razor index 4803ba5..4d8f738 100644 --- a/WatchIt.Website/WatchIt.Website/Components/LoadingComponent.razor +++ b/WatchIt.Website/WatchIt.Website/Components/Common/Subcomponents/LoadingComponent.razor @@ -1,8 +1,8 @@ 
-
+
-

Loading...

+

Loading...

\ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Components/Common/Subcomponents/LoadingComponent.razor.cs b/WatchIt.Website/WatchIt.Website/Components/Common/Subcomponents/LoadingComponent.razor.cs new file mode 100644 index 0000000..de811d9 --- /dev/null +++ b/WatchIt.Website/WatchIt.Website/Components/Common/Subcomponents/LoadingComponent.razor.cs @@ -0,0 +1,47 @@ +using System.ComponentModel; +using System.Reflection; +using Microsoft.AspNetCore.Components; + +namespace WatchIt.Website.Components.Common.Subcomponents; + +public partial class LoadingComponent : ComponentBase +{ + #region PARAMETERS + + [Parameter] public LoadingComponentColors Color { get; set; } = LoadingComponentColors.Dark; + + #endregion + + + + #region PRIVATE METHODS + + private string GetColor() + { + DescriptionAttribute? attribute = Color.GetType() + .GetTypeInfo() + .GetMember(Color.ToString()) + .FirstOrDefault(member => member.MemberType == MemberTypes.Field)! + .GetCustomAttributes(typeof(DescriptionAttribute), false) + .SingleOrDefault() + as DescriptionAttribute; + return attribute!.Description; + } + + #endregion + + + + #region ENUMS + + public enum LoadingComponentColors + { + [Description("dark")] + Dark, + + [Description("light")] + Light, + } + + #endregion +} \ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Components/LoadingComponent.razor.css b/WatchIt.Website/WatchIt.Website/Components/Common/Subcomponents/LoadingComponent.razor.css similarity index 100% rename from WatchIt.Website/WatchIt.Website/Components/LoadingComponent.razor.css rename to WatchIt.Website/WatchIt.Website/Components/Common/Subcomponents/LoadingComponent.razor.css diff --git a/WatchIt.Website/WatchIt.Website/Components/Common/Subcomponents/PictureComponent.razor b/WatchIt.Website/WatchIt.Website/Components/Common/Subcomponents/PictureComponent.razor new file mode 100644 index 0000000..398c4d6 --- /dev/null +++ b/WatchIt.Website/WatchIt.Website/Components/Common/Subcomponents/PictureComponent.razor @@ -0,0 +1 @@ +@(AlternativeText) \ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Components/Common/Subcomponents/PictureComponent.razor.cs b/WatchIt.Website/WatchIt.Website/Components/Common/Subcomponents/PictureComponent.razor.cs new file mode 100644 index 0000000..213b9c2 --- /dev/null +++ b/WatchIt.Website/WatchIt.Website/Components/Common/Subcomponents/PictureComponent.razor.cs @@ -0,0 +1,87 @@ +using Microsoft.AspNetCore.Components; +using WatchIt.Common.Model; + +namespace WatchIt.Website.Components.Common.Subcomponents; + +public partial class PictureComponent : ComponentBase +{ + #region PARAMETERS + + [Parameter] public Picture? Picture { get; set; } + [Parameter] public required string Placeholder { get; set; } + [Parameter] public PictureComponentAspectRatio AspectRatio { get; set; } = PictureComponentAspectRatio.Default; + [Parameter] public string AlternativeText { get; set; } = "picture"; + [Parameter] public string Class { get; set; } = string.Empty; + [Parameter] public int? Height { get; set; } + [Parameter] public int? Width { get; set; } + + #endregion + + + + #region FIELDS + + private Dictionary _attributes = []; + + #endregion + + + + #region PRIVATE METHODS + + protected override void OnParametersSet() + { + _attributes.Clear(); + if (Height.HasValue) + { + _attributes.Add("height", Height.Value); + } + else if (Width.HasValue) + { + _attributes.Add("width", Width.Value); + } + } + + #endregion + + + + #region STRUCTS + + public struct PictureComponentAspectRatio + { + #region Properties + + public int Vertical { get; set; } + public int Horizontal { get; set; } + + #endregion + + + + #region Constructors + + public PictureComponentAspectRatio() : this(3, 5) {} + + public PictureComponentAspectRatio(int horizontal, int vertical) + { + Horizontal = horizontal; + Vertical = vertical; + } + + public static readonly PictureComponentAspectRatio Default = new PictureComponentAspectRatio(); + public static readonly PictureComponentAspectRatio Photo = new PictureComponentAspectRatio(16, 9); + + #endregion + + + + #region Public methods + + public override string ToString() => $"{Horizontal}/{Vertical}"; + + #endregion + } + + #endregion +} \ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Components/Common/Subcomponents/RoleListComponent.razor b/WatchIt.Website/WatchIt.Website/Components/Common/Subcomponents/RoleListComponent.razor new file mode 100644 index 0000000..01b8398 --- /dev/null +++ b/WatchIt.Website/WatchIt.Website/Components/Common/Subcomponents/RoleListComponent.razor @@ -0,0 +1,58 @@ +@typeparam TRole where TRole : WatchIt.Common.Model.Roles.IRoleResponse, WatchIt.Common.Query.IQueryOrderable +@typeparam TQuery where TQuery : WatchIt.Common.Query.QueryParameters +@typeparam TRoleParent + + + +@if (_loaded) +{ + if (_roles.Count > 0) + { +
+ @for (int i = 0; i < _roles.Count; i++) + { + { + int iCopy = i; + KeyValuePair roleParentPair = _roles.ElementAt(i); + TRole role = roleParentPair.Key; + TRoleParent parent = roleParentPair.Value; + string url = string.Format(ParentUrlTemplate, ParentItemIdSource(role)); + if (i > 0) + { +
+ } + + } + } + @if (!_allItemsLoaded) + { +
+ +
+ } +
+ } + else + { + No roles found + } +} +else +{ + +} \ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Components/Common/Subcomponents/RoleListComponent.razor.cs b/WatchIt.Website/WatchIt.Website/Components/Common/Subcomponents/RoleListComponent.razor.cs new file mode 100644 index 0000000..8e5f918 --- /dev/null +++ b/WatchIt.Website/WatchIt.Website/Components/Common/Subcomponents/RoleListComponent.razor.cs @@ -0,0 +1,119 @@ +using Microsoft.AspNetCore.Components; +using WatchIt.Common.Model; +using WatchIt.Common.Model.Rating; + +namespace WatchIt.Website.Components.Common.Subcomponents; + +public partial class RoleListComponent : ComponentBase where TRole : WatchIt.Common.Model.Roles.IRoleResponse, WatchIt.Common.Query.IQueryOrderable + where TQuery : WatchIt.Common.Query.QueryParameters +{ + #region PARAMETERS + + [Parameter] public required long Id { get; set; } + [Parameter] public TQuery Query { get; set; } = Activator.CreateInstance(); + [Parameter] public required Func>, Task> GetRolesAction { get; set; } + + [Parameter] public required Func NameSource { get; set; } + [Parameter] public Func? AdditionalInfoSource { get; set; } + + [Parameter] public required Func, Task> GetRoleParentMethod { get; set; } + [Parameter] public required Func ParentItemIdSource { get; set; } + [Parameter] public required string ParentUrlTemplate { get; set; } + + [Parameter] public required string PosterPlaceholder { get; set; } + [Parameter] public required Func, Task> PosterDownloadingTask { get; set; } + + [Parameter] public required Func, Task> GetGlobalRatingMethod { get; set; } + [Parameter] public required Func, Action, Task> GetUserRatingMethod { get; set; } + [Parameter] public required Func PutRatingMethod { get; set; } + [Parameter] public required Func DeleteRatingMethod { get; set; } + + [Parameter] public Action? OnRatingChanged { get; set; } + + #endregion + + + + #region FIELDS + + private readonly int _pageSize = 20; + + private bool _loaded; + private bool _allItemsLoaded; + + private Dictionary _roles = new Dictionary(); + private bool _rolesFetching; + + #endregion + + + + #region PUBLIC METHODS + + public async Task Refresh() + { + _loaded = false; + _roles.Clear(); + Query.After = null; + Query.First = _pageSize; + await GetRoles(true); + _loaded = true; + } + + #endregion + + + + #region PRIVATE METHODS + + protected override async Task OnAfterRenderAsync(bool firstRender) + { + if (firstRender) + { + List endTasks = new List(); + + // INIT + Query.First = _pageSize; + Query.OrderBy = "rating.average"; + + // STEP 0 + endTasks.AddRange( + [ + GetRoles(true) + ]); + + // END + await Task.WhenAll(endTasks); + } + } + + private async Task GetRoles(bool firstFetch = false) + { + _rolesFetching = true; + await GetRolesAction(Id, Query, async data => + { + foreach (TRole item in data) + { + await GetRoleParentMethod(ParentItemIdSource(item), parent => _roles[item] = parent); + } + if (data.Count() < _pageSize) + { + _allItemsLoaded = true; + } + else + { + if (firstFetch) + { + Query.After = 0; + } + } + Query.After += data.Count(); + _rolesFetching = false; + + _loaded = true; + StateHasChanged(); + }); + } + + #endregion +} \ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Components/Common/Subcomponents/TitledDisplayRatingComponent.razor b/WatchIt.Website/WatchIt.Website/Components/Common/Subcomponents/TitledDisplayRatingComponent.razor new file mode 100644 index 0000000..6eb08a6 --- /dev/null +++ b/WatchIt.Website/WatchIt.Website/Components/Common/Subcomponents/TitledDisplayRatingComponent.razor @@ -0,0 +1,10 @@ +
+
+
+ @(Title) +
+
+ +
+
+
\ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Components/Common/Subcomponents/TitledDisplayRatingComponent.razor.cs b/WatchIt.Website/WatchIt.Website/Components/Common/Subcomponents/TitledDisplayRatingComponent.razor.cs new file mode 100644 index 0000000..937e658 --- /dev/null +++ b/WatchIt.Website/WatchIt.Website/Components/Common/Subcomponents/TitledDisplayRatingComponent.razor.cs @@ -0,0 +1,14 @@ +using Microsoft.AspNetCore.Components; +using WatchIt.Common.Model.Rating; + +namespace WatchIt.Website.Components.Common.Subcomponents; + +public partial class TitledDisplayRatingComponent : ComponentBase +{ + #region PARAMETERS + + [Parameter] public required RatingResponse Rating { get; set; } + [Parameter] public required string Title { get; set; } + + #endregion +} \ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Components/Common/Subcomponents/TitledDisplayRatingComponent.razor.css b/WatchIt.Website/WatchIt.Website/Components/Common/Subcomponents/TitledDisplayRatingComponent.razor.css new file mode 100644 index 0000000..f0c49bb --- /dev/null +++ b/WatchIt.Website/WatchIt.Website/Components/Common/Subcomponents/TitledDisplayRatingComponent.razor.css @@ -0,0 +1,5 @@ +/* IDS */ + +#title { + font-size: 1.5rem; +} \ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Components/ErrorComponent.razor b/WatchIt.Website/WatchIt.Website/Components/ErrorComponent.razor deleted file mode 100644 index bc34f73..0000000 --- a/WatchIt.Website/WatchIt.Website/Components/ErrorComponent.razor +++ /dev/null @@ -1,28 +0,0 @@ -
-
-
-
-
-
⚠︎
-
-
-
-
-
-
-

An error occured while loading a page

-
-
-
- @if (!string.IsNullOrWhiteSpace(ErrorMessage)) - { -
-
-
-

@ErrorMessage

-
-
-
- } -
-
\ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Components/ListItemComponent.razor b/WatchIt.Website/WatchIt.Website/Components/ListItemComponent.razor deleted file mode 100644 index 566d09b..0000000 --- a/WatchIt.Website/WatchIt.Website/Components/ListItemComponent.razor +++ /dev/null @@ -1,26 +0,0 @@ -
-
-
- picture -
-
-
-
- - @(Name)@(string.IsNullOrWhiteSpace(AdditionalNameInfo) ? string.Empty : AdditionalNameInfo) - -
-
- -
- @(Rating.Count > 0 ? Rating.Average : "--")/10 - @if (Rating.Count > 0) - { - @(Rating.Count) - } -
-
-
-
-
-
\ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Components/ListItemComponent.razor.css b/WatchIt.Website/WatchIt.Website/Components/ListItemComponent.razor.css deleted file mode 100644 index 91b920c..0000000 --- a/WatchIt.Website/WatchIt.Website/Components/ListItemComponent.razor.css +++ /dev/null @@ -1,17 +0,0 @@ -/* IDS */ - -#nameText { - font-size: 25px; -} - -#ratingStar { - font-size: 30px; -} - -#ratingValue { - font-size: 20px; -} - -#ratingCount { - font-size: 10px; -} \ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Components/LoadingComponent.razor.cs b/WatchIt.Website/WatchIt.Website/Components/LoadingComponent.razor.cs deleted file mode 100644 index 2ab6e66..0000000 --- a/WatchIt.Website/WatchIt.Website/Components/LoadingComponent.razor.cs +++ /dev/null @@ -1,12 +0,0 @@ -using Microsoft.AspNetCore.Components; - -namespace WatchIt.Website.Components; - -public partial class LoadingComponent : ComponentBase -{ - #region PARAMETERS - - [Parameter] public string Color { get; set; } = "dark"; - - #endregion -} \ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Components/DatabasePage/DatabasePageComponent.razor b/WatchIt.Website/WatchIt.Website/Components/Pages/DatabasePage/DatabasePageComponent.razor similarity index 55% rename from WatchIt.Website/WatchIt.Website/Components/DatabasePage/DatabasePageComponent.razor rename to WatchIt.Website/WatchIt.Website/Components/Pages/DatabasePage/DatabasePageComponent.razor index 10b6ed6..0a3738a 100644 --- a/WatchIt.Website/WatchIt.Website/Components/DatabasePage/DatabasePageComponent.razor +++ b/WatchIt.Website/WatchIt.Website/Components/Pages/DatabasePage/DatabasePageComponent.razor @@ -48,36 +48,54 @@ { if (string.IsNullOrWhiteSpace(_error)) { - foreach (TItem item in _items) + if (_items.Count > 0) { -
- -
+ foreach (TItem item in _items) + { + long id = IdSource(item); + string url = string.Format(UrlIdTemplate, id); +
+ +
+ } + if (!_allItemsLoaded) + { +
+
+ @if (!_itemsLoading) + { + Load more + } + else + { + + Loading... + } +
+
+ } } - if (!_allItemsLoaded) + else { -
+
- @if (!_itemsLoading) - { - Load more - } - else - { - - Loading... - } + No items found
} } else { - + } } else diff --git a/WatchIt.Website/WatchIt.Website/Components/DatabasePage/DatabasePageComponent.razor.cs b/WatchIt.Website/WatchIt.Website/Components/Pages/DatabasePage/DatabasePageComponent.razor.cs similarity index 87% rename from WatchIt.Website/WatchIt.Website/Components/DatabasePage/DatabasePageComponent.razor.cs rename to WatchIt.Website/WatchIt.Website/Components/Pages/DatabasePage/DatabasePageComponent.razor.cs index 84ff2b8..6d07ab9 100644 --- a/WatchIt.Website/WatchIt.Website/Components/DatabasePage/DatabasePageComponent.razor.cs +++ b/WatchIt.Website/WatchIt.Website/Components/Pages/DatabasePage/DatabasePageComponent.razor.cs @@ -4,7 +4,7 @@ using WatchIt.Common.Model.Movies; using WatchIt.Common.Model.Rating; using WatchIt.Common.Query; -namespace WatchIt.Website.Components.DatabasePage; +namespace WatchIt.Website.Components.Pages.DatabasePage; public partial class DatabasePageComponent : ComponentBase where TItem : IQueryOrderable where TQuery : QueryParameters { @@ -28,6 +28,12 @@ public partial class DatabasePageComponent : ComponentBase where [Parameter] public required Func>, Task> ItemDownloadingTask { get; set; } [Parameter] public required Dictionary SortingOptions { get; set; } [Parameter] public required RenderFragment ChildContent { get; set; } + [Parameter] public required Func, Task> GetGlobalRatingMethod { get; set; } + [Parameter] public Func, Action, Task>? GetUserRatingMethod { get; set; } + [Parameter] public Func? PutRatingMethod { get; set; } + [Parameter] public Func? DeleteRatingMethod { get; set; } + [Parameter] public required string PosterPlaceholder { get; set; } + #endregion diff --git a/WatchIt.Website/WatchIt.Website/Components/DatabasePage/FilterFormComponent.cs b/WatchIt.Website/WatchIt.Website/Components/Pages/DatabasePage/Subcomponents/FilterFormComponent.cs similarity index 86% rename from WatchIt.Website/WatchIt.Website/Components/DatabasePage/FilterFormComponent.cs rename to WatchIt.Website/WatchIt.Website/Components/Pages/DatabasePage/Subcomponents/FilterFormComponent.cs index 26fa16d..1df000c 100644 --- a/WatchIt.Website/WatchIt.Website/Components/DatabasePage/FilterFormComponent.cs +++ b/WatchIt.Website/WatchIt.Website/Components/Pages/DatabasePage/Subcomponents/FilterFormComponent.cs @@ -1,7 +1,7 @@ using Microsoft.AspNetCore.Components; using WatchIt.Common.Query; -namespace WatchIt.Website.Components.DatabasePage; +namespace WatchIt.Website.Components.Pages.DatabasePage.Subcomponents; public abstract class FilterFormComponent : ComponentBase where TItem : IQueryOrderable where TQuery : QueryParameters { diff --git a/WatchIt.Website/WatchIt.Website/Components/DatabasePage/MoviesFilterFormComponent.razor b/WatchIt.Website/WatchIt.Website/Components/Pages/DatabasePage/Subcomponents/MoviesFilterFormComponent.razor similarity index 100% rename from WatchIt.Website/WatchIt.Website/Components/DatabasePage/MoviesFilterFormComponent.razor rename to WatchIt.Website/WatchIt.Website/Components/Pages/DatabasePage/Subcomponents/MoviesFilterFormComponent.razor diff --git a/WatchIt.Website/WatchIt.Website/Components/Pages/DatabasePage/Subcomponents/PersonsFilterFormComponent.razor b/WatchIt.Website/WatchIt.Website/Components/Pages/DatabasePage/Subcomponents/PersonsFilterFormComponent.razor new file mode 100644 index 0000000..7f251bf --- /dev/null +++ b/WatchIt.Website/WatchIt.Website/Components/Pages/DatabasePage/Subcomponents/PersonsFilterFormComponent.razor @@ -0,0 +1,71 @@ +@using WatchIt.Common.Model.Genders +@inherits FilterFormComponent + + + + +
+
+
+ Name + +
+
+
+
+ Full name + +
+
+
+
+ Description + +
+
+
+
+ Birth date + + - + +
+
+
+
+ Death date + + - + +
+
+
+
+ Gender + + + @foreach (GenderResponse gender in _genders) + { + + } + +
+
+
+
+ Rating (count) + + - + +
+
+
+
+ Rating (average) + + - + +
+
+
+
\ No newline at end of file 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 new file mode 100644 index 0000000..ca4f085 --- /dev/null +++ b/WatchIt.Website/WatchIt.Website/Components/Pages/DatabasePage/Subcomponents/PersonsFilterFormComponent.razor.cs @@ -0,0 +1,48 @@ +using Microsoft.AspNetCore.Components; +using WatchIt.Common.Model.Genders; +using WatchIt.Common.Model.Persons; +using WatchIt.Website.Services.WebAPI.Genders; + +namespace WatchIt.Website.Components.Pages.DatabasePage.Subcomponents; + +public partial class PersonsFilterFormComponent : FilterFormComponent +{ + #region SERVICES + + [Inject] private IGendersWebAPIService GendersWebAPIService { get; set; } = default!; + + #endregion + + + + #region FIELDS + + private IEnumerable _genders = []; + + #endregion + + + + #region PRIVATE METHODS + + protected override async Task OnAfterRenderAsync(bool firstRender) + { + if (firstRender) + { + List endTasks = new List(); + + // STEP 0 + endTasks.AddRange( + [ + GendersWebAPIService.GetAllGenders(successAction: data => _genders = data) + ]); + + // END + await Task.WhenAll(endTasks); + + StateHasChanged(); + } + } + + #endregion +} \ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Components/DatabasePage/SeriesFilterFormComponent.razor b/WatchIt.Website/WatchIt.Website/Components/Pages/DatabasePage/Subcomponents/SeriesFilterFormComponent.razor similarity index 100% rename from WatchIt.Website/WatchIt.Website/Components/DatabasePage/SeriesFilterFormComponent.razor rename to WatchIt.Website/WatchIt.Website/Components/Pages/DatabasePage/Subcomponents/SeriesFilterFormComponent.razor diff --git a/WatchIt.Website/WatchIt.Website/Components/Pages/HomePage/Panels/ViewRankPanelComponent.razor b/WatchIt.Website/WatchIt.Website/Components/Pages/HomePage/Panels/ViewRankPanelComponent.razor new file mode 100644 index 0000000..572eb03 --- /dev/null +++ b/WatchIt.Website/WatchIt.Website/Components/Pages/HomePage/Panels/ViewRankPanelComponent.razor @@ -0,0 +1,37 @@ +@using WatchIt.Website.Components.Pages.HomePage.Subcomponents + +@typeparam TItem + + + +
+
+ Top @(Count) @(Name) this week by popularity + @if (_loaded) + { +
+
+ @for (int i = 0; i < Count; i++) + { +
+ @if (_items.Count() > i) + { + + @{int iCopy = i;} + + + } +
+ } +
+
+ } + else + { + + } +
+
\ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Components/Pages/HomePage/Panels/ViewRankPanelComponent.razor.cs b/WatchIt.Website/WatchIt.Website/Components/Pages/HomePage/Panels/ViewRankPanelComponent.razor.cs new file mode 100644 index 0000000..61d983d --- /dev/null +++ b/WatchIt.Website/WatchIt.Website/Components/Pages/HomePage/Panels/ViewRankPanelComponent.razor.cs @@ -0,0 +1,58 @@ +using Blazorise.Components.Autocomplete; +using Microsoft.AspNetCore.Components; +using WatchIt.Common.Model; +using WatchIt.Common.Query; + +namespace WatchIt.Website.Components.Pages.HomePage.Panels; + +public partial class ViewRankPanelComponent : ComponentBase +{ + #region PARAMETERS + + [Parameter] public int Count { get; set; } = 5; + [Parameter] public required string Name {get; set; } + [Parameter] public required Func>, Task> GetViewRankAction { get; set; } + [Parameter] public required string ItemUrlFormatString { get; set; } + [Parameter] public required Func IdSource { get; set; } + [Parameter] public required Func NameSource { get; set; } + [Parameter] public required string PosterPlaceholder {get; set; } + [Parameter] public required Func, Task> GetPictureAction { get; set; } + + #endregion + + + + #region FIELDS + + private bool _loaded; + + private IEnumerable _items = default!; + + #endregion + + + + #region PRIVATE METHODS + + protected override async Task OnAfterRenderAsync(bool firstRender) + { + if (firstRender) + { + List endTasks = new List(); + + // STEP 0 + endTasks.AddRange( + [ + GetViewRankAction(Count, data => _items = data) + ]); + + // END + await Task.WhenAll(endTasks); + + _loaded = true; + StateHasChanged(); + } + } + + #endregion +} \ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Components/Pages/HomePage/Subcomponents/ViewRankItemComponent.razor b/WatchIt.Website/WatchIt.Website/Components/Pages/HomePage/Subcomponents/ViewRankItemComponent.razor new file mode 100644 index 0000000..89c1a89 --- /dev/null +++ b/WatchIt.Website/WatchIt.Website/Components/Pages/HomePage/Subcomponents/ViewRankItemComponent.razor @@ -0,0 +1,13 @@ +
+ +
+
+
+
@(Place)
+
+
+
@(Name)
+
+
+
+
\ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Components/ListItemComponent.razor.cs b/WatchIt.Website/WatchIt.Website/Components/Pages/HomePage/Subcomponents/ViewRankItemComponent.razor.cs similarity index 50% rename from WatchIt.Website/WatchIt.Website/Components/ListItemComponent.razor.cs rename to WatchIt.Website/WatchIt.Website/Components/Pages/HomePage/Subcomponents/ViewRankItemComponent.razor.cs index bd6713f..16ec507 100644 --- a/WatchIt.Website/WatchIt.Website/Components/ListItemComponent.razor.cs +++ b/WatchIt.Website/WatchIt.Website/Components/Pages/HomePage/Subcomponents/ViewRankItemComponent.razor.cs @@ -1,36 +1,31 @@ using Microsoft.AspNetCore.Components; using WatchIt.Common.Model; -using WatchIt.Common.Model.Rating; -namespace WatchIt.Website.Components; +namespace WatchIt.Website.Components.Pages.HomePage.Subcomponents; -public partial class ListItemComponent : ComponentBase +public partial class ViewRankItemComponent : ComponentBase { #region PARAMETERS - [Parameter] public required long Id { get; set; } + [Parameter] public required int Place { get; set; } [Parameter] public required string Name { get; set; } - [Parameter] public string? AdditionalNameInfo { get; set; } - [Parameter] public required RatingResponse Rating { get; set; } - [Parameter] public required Func, Task> PictureDownloadingTask { get; set; } - [Parameter] public int PictureHeight { get; set; } = 150; - + [Parameter] public required string PosterPlaceholder { get; set; } + [Parameter] public required Func, Task> GetPosterAction { get; set; } + #endregion #region FIELDS - private bool _loaded; - - private Picture? _picture; + private Picture? _poster; #endregion #region PRIVATE METHODS - + protected override async Task OnAfterRenderAsync(bool firstRender) { if (firstRender) @@ -40,15 +35,15 @@ public partial class ListItemComponent : ComponentBase // STEP 0 endTasks.AddRange( [ - PictureDownloadingTask(Id, picture => _picture = picture), + GetPosterAction(data => _poster = data), ]); + // END await Task.WhenAll(endTasks); - _loaded = true; StateHasChanged(); } } - + #endregion } \ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Components/Pages/HomePage/Subcomponents/ViewRankItemComponent.razor.css b/WatchIt.Website/WatchIt.Website/Components/Pages/HomePage/Subcomponents/ViewRankItemComponent.razor.css new file mode 100644 index 0000000..aa8b68f --- /dev/null +++ b/WatchIt.Website/WatchIt.Website/Components/Pages/HomePage/Subcomponents/ViewRankItemComponent.razor.css @@ -0,0 +1,12 @@ +/* CLASSES */ + +.border-2 { + border-width: 2px; +} + +.place-circle { + width: 30px; + height: 30px; + vertical-align: middle; + line-height: 25px; +} \ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Components/Pages/MediaEditPage/Panels/MediaActorRolesEditPanelComponent.razor b/WatchIt.Website/WatchIt.Website/Components/Pages/MediaEditPage/Panels/MediaActorRolesEditPanelComponent.razor new file mode 100644 index 0000000..24575e5 --- /dev/null +++ b/WatchIt.Website/WatchIt.Website/Components/Pages/MediaEditPage/Panels/MediaActorRolesEditPanelComponent.razor @@ -0,0 +1,156 @@ +@using Blazorise.Extensions +@using WatchIt.Common.Model.Roles +@using Blazorise.Components +@using WatchIt.Common.Model.Persons + + + +
+ @if (_loaded) + { +
+
+
+
+

Actor roles

+
+ @if (!_editingMode) + { +
+ +
+ } + else + { + if (!string.IsNullOrWhiteSpace(_error)) + { +
+ @(_error) +
+ } +
+ +
+
+ +
+ } +
+
+ @if (!_editingMode) + { + if (_roles.IsNullOrEmpty()) + { + No items + } + else + { + + + + + + + + + + + @foreach (Guid roleId in _roles.Keys) + { + + + + + + + } + +
+ Person + + Role type + + Role name + + Actions +
+ @(Persons[_roles[roleId].Data.PersonId].Name) + + @(_roleTypes[_roles[roleId].Data.TypeId]) + + @(_roles[roleId].Data.Name) + +
+ + +
+
+ } + } + else + { + + +
+
+ +
+ + Sorry... @not_found_context was not found + +
+
+
+ +
+ + @foreach (KeyValuePair type in _roleTypes) + { + + } + +
+
+
+ +
+ +
+
+
+
+ } +
+ } + else + { + + } +
\ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Components/Pages/MediaEditPage/Panels/MediaActorRolesEditPanelComponent.razor.cs b/WatchIt.Website/WatchIt.Website/Components/Pages/MediaEditPage/Panels/MediaActorRolesEditPanelComponent.razor.cs new file mode 100644 index 0000000..f152025 --- /dev/null +++ b/WatchIt.Website/WatchIt.Website/Components/Pages/MediaEditPage/Panels/MediaActorRolesEditPanelComponent.razor.cs @@ -0,0 +1,148 @@ +using Microsoft.AspNetCore.Components; +using WatchIt.Common.Model.Media; +using WatchIt.Common.Model.Persons; +using WatchIt.Common.Model.Roles; +using WatchIt.Website.Services.WebAPI.Media; +using WatchIt.Website.Services.WebAPI.Persons; +using WatchIt.Website.Services.WebAPI.Roles; + +namespace WatchIt.Website.Components.Pages.MediaEditPage.Panels; + +public partial class MediaActorRolesEditPanelComponent : ComponentBase +{ + #region SERVICES + + [Inject] private IPersonsWebAPIService PersonsWebAPIService { get; set; } = default!; + [Inject] private IMediaWebAPIService MediaWebAPIService { get; set; } = default!; + [Inject] private IRolesWebAPIService RolesWebAPIService { get; set; } = default!; + + #endregion + + + + #region PARAMETERS + + [Parameter] public required long? Id { get; set; } + [Parameter] public required Dictionary Persons { get; set; } + [Parameter] public string Class { get; set; } = string.Empty; + + #endregion + + + + #region FIELDS + + private bool _loaded; + private string? _error; + + private Dictionary _roles = []; + private Dictionary _roleTypes = []; + + + private Guid? _editedId; + private IActorRoleMediaRequest? _editedModel; + + private bool _editingMode; + private bool _saving; + + #endregion + + + + #region PUBLIC METHODS + + protected override async Task OnAfterRenderAsync(bool firstRender) + { + if (firstRender) + { + List endTasks = new List(); + + // STEP 0 + if (Id.HasValue) + { + endTasks.AddRange( + [ + MediaWebAPIService.GetMediaAllActorRoles(Id.Value, successAction: data => _roles = data.ToDictionary(x => x.Id, x => (x, false))), + RolesWebAPIService.GetAllActorRoleTypes(successAction: data => _roleTypes = data.ToDictionary(x => x.Id, x => x.Name)), + ]); + } + + // END + await Task.WhenAll(endTasks); + + _loaded = true; + StateHasChanged(); + } + } + + private void CancelEdit() + { + _error = null; + _editingMode = false; + } + + private async Task SaveEdit() + { + void SuccessPost(ActorRoleResponse data) + { + _roles[data.Id] = (data, false); + + _saving = false; + _editingMode = false; + } + + void SuccessPut() + { + ActorRoleResponse temp = _roles[_editedId!.Value].Data; + temp.PersonId = _editedModel.PersonId; + temp.TypeId = _editedModel.TypeId; + temp.Name = _editedModel.Name; + + _roles[_editedId!.Value] = (temp, false); + + _saving = false; + _editingMode = false; + } + + void BadRequest(IDictionary errors) + { + _error = errors.SelectMany(x => x.Value).FirstOrDefault() ?? "Unknown error"; + _saving = false; + } + + void Unauthorized() + { + _error = "You do not have permission to do this"; + _saving = false; + } + + _error = null; + _saving = true; + if (_editedId.HasValue) + { + await RolesWebAPIService.PutActorRole(_editedId.Value, _editedModel as ActorRoleUniversalRequest, SuccessPut, BadRequest, Unauthorized); + } + else + { + await MediaWebAPIService.PostMediaActorRole(Id!.Value, _editedModel as ActorRoleMediaRequest, SuccessPost, BadRequest, Unauthorized); + } + } + + private void ActivateEdit(Guid? id = null) + { + _editedId = id; + _editedModel = id.HasValue ? new ActorRoleUniversalRequest(_roles[id.Value].Data) : new ActorRoleMediaRequest() + { + TypeId = _roleTypes.Keys.First() + }; + _editingMode = true; + } + + private async Task Delete(Guid id) + { + _roles[id] = (_roles[id].Data, true); + await RolesWebAPIService.DeleteActorRole(id, () => _roles.Remove(id)); + } + + #endregion +} \ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Components/Pages/MediaEditPage/Panels/MediaCreatorRolesEditPanelComponent.razor b/WatchIt.Website/WatchIt.Website/Components/Pages/MediaEditPage/Panels/MediaCreatorRolesEditPanelComponent.razor new file mode 100644 index 0000000..199f2e2 --- /dev/null +++ b/WatchIt.Website/WatchIt.Website/Components/Pages/MediaEditPage/Panels/MediaCreatorRolesEditPanelComponent.razor @@ -0,0 +1,142 @@ +@using Blazorise.Extensions +@using Blazorise.Components +@using WatchIt.Common.Model.Persons + + +
+ @if (_loaded) + { +
+
+
+
+

Creator roles

+
+ @if (!_editingMode) + { +
+ +
+ } + else + { + if (!string.IsNullOrWhiteSpace(_error)) + { +
+ @(_error) +
+ } +
+ +
+
+ +
+ } +
+
+ @if (!_editingMode) + { + if (_roles.IsNullOrEmpty()) + { + No items + } + else + { + + + + + + + + + + @foreach (Guid roleId in _roles.Keys) + { + + + + + + } + +
+ Person + + Role type + + Actions +
+ @(Persons[_roles[roleId].Data.PersonId].Name) + + @(_roleTypes[_roles[roleId].Data.TypeId]) + +
+ + +
+
+ } + } + else + { + + +
+
+ +
+ + Sorry... @not_found_context was not found + +
+
+
+ +
+ + @foreach (KeyValuePair type in _roleTypes) + { + + } + +
+
+
+
+ } +
+ } + else + { + + } +
\ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Components/Pages/MediaEditPage/Panels/MediaCreatorRolesEditPanelComponent.razor.cs b/WatchIt.Website/WatchIt.Website/Components/Pages/MediaEditPage/Panels/MediaCreatorRolesEditPanelComponent.razor.cs new file mode 100644 index 0000000..46c61c7 --- /dev/null +++ b/WatchIt.Website/WatchIt.Website/Components/Pages/MediaEditPage/Panels/MediaCreatorRolesEditPanelComponent.razor.cs @@ -0,0 +1,147 @@ +using Microsoft.AspNetCore.Components; +using WatchIt.Common.Model.Media; +using WatchIt.Common.Model.Persons; +using WatchIt.Common.Model.Roles; +using WatchIt.Website.Services.WebAPI.Media; +using WatchIt.Website.Services.WebAPI.Persons; +using WatchIt.Website.Services.WebAPI.Roles; + +namespace WatchIt.Website.Components.Pages.MediaEditPage.Panels; + +public partial class MediaCreatorRolesEditPanelComponent : ComponentBase +{ + #region SERVICES + + [Inject] private IPersonsWebAPIService PersonsWebAPIService { get; set; } = default!; + [Inject] private IMediaWebAPIService MediaWebAPIService { get; set; } = default!; + [Inject] private IRolesWebAPIService RolesWebAPIService { get; set; } = default!; + + #endregion + + + + #region PARAMETERS + + [Parameter] public required long? Id { get; set; } + [Parameter] public required Dictionary Persons { get; set; } + [Parameter] public string Class { get; set; } = string.Empty; + + #endregion + + + + #region FIELDS + + private bool _loaded; + private string? _error; + + private Dictionary _roles = []; + private Dictionary _roleTypes = []; + + + private Guid? _editedId; + private ICreatorRoleMediaRequest? _editedModel; + + private bool _editingMode; + private bool _saving; + + #endregion + + + + #region PUBLIC METHODS + + protected override async Task OnAfterRenderAsync(bool firstRender) + { + if (firstRender) + { + List endTasks = new List(); + + // STEP 0 + if (Id.HasValue) + { + endTasks.AddRange( + [ + MediaWebAPIService.GetMediaAllCreatorRoles(Id.Value, successAction: data => _roles = data.ToDictionary(x => x.Id, x => (x, false))), + RolesWebAPIService.GetAllCreatorRoleTypes(successAction: data => _roleTypes = data.ToDictionary(x => x.Id, x => x.Name)), + ]); + } + + // END + await Task.WhenAll(endTasks); + + _loaded = true; + StateHasChanged(); + } + } + + private void CancelEdit() + { + _error = null; + _editingMode = false; + } + + private async Task SaveEdit() + { + void SuccessPost(CreatorRoleResponse data) + { + _roles[data.Id] = (data, false); + + _saving = false; + _editingMode = false; + } + + void SuccessPut() + { + CreatorRoleResponse temp = _roles[_editedId!.Value].Data; + temp.PersonId = _editedModel.PersonId; + temp.TypeId = _editedModel.TypeId; + + _roles[_editedId!.Value] = (temp, false); + + _saving = false; + _editingMode = false; + } + + void BadRequest(IDictionary errors) + { + _error = errors.SelectMany(x => x.Value).FirstOrDefault() ?? "Unknown error"; + _saving = false; + } + + void Unauthorized() + { + _error = "You do not have permission to do this"; + _saving = false; + } + + _error = null; + _saving = true; + if (_editedId.HasValue) + { + await RolesWebAPIService.PutCreatorRole(_editedId.Value, _editedModel as CreatorRoleUniversalRequest, SuccessPut, BadRequest, Unauthorized); + } + else + { + await MediaWebAPIService.PostMediaCreatorRole(Id!.Value, _editedModel as CreatorRoleMediaRequest, SuccessPost, BadRequest, Unauthorized); + } + } + + private void ActivateEdit(Guid? id = null) + { + _editedId = id; + _editedModel = id.HasValue ? new CreatorRoleUniversalRequest(_roles[id.Value].Data) : new CreatorRoleMediaRequest() + { + TypeId = _roleTypes.Keys.First() + }; + _editingMode = true; + } + + private async Task Delete(Guid id) + { + _roles[id] = (_roles[id].Data, true); + await RolesWebAPIService.DeleteCreatorRole(id, () => _roles.Remove(id)); + } + + #endregion +} \ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Components/Pages/MediaPage/Panels/MediaActorRolesPanelComponent.razor b/WatchIt.Website/WatchIt.Website/Components/Pages/MediaPage/Panels/MediaActorRolesPanelComponent.razor new file mode 100644 index 0000000..80804ab --- /dev/null +++ b/WatchIt.Website/WatchIt.Website/Components/Pages/MediaPage/Panels/MediaActorRolesPanelComponent.razor @@ -0,0 +1,26 @@ +@using WatchIt.Common.Model.Persons +@using WatchIt.Common.Model.Roles + + + +
+
+ Actors + +
+
\ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Components/Pages/MediaPage/Panels/MediaActorRolesPanelComponent.razor.cs b/WatchIt.Website/WatchIt.Website/Components/Pages/MediaPage/Panels/MediaActorRolesPanelComponent.razor.cs new file mode 100644 index 0000000..54e7287 --- /dev/null +++ b/WatchIt.Website/WatchIt.Website/Components/Pages/MediaPage/Panels/MediaActorRolesPanelComponent.razor.cs @@ -0,0 +1,27 @@ +using Microsoft.AspNetCore.Components; +using WatchIt.Website.Services.Utility.Authentication; +using WatchIt.Website.Services.WebAPI.Media; +using WatchIt.Website.Services.WebAPI.Persons; +using WatchIt.Website.Services.WebAPI.Roles; + +namespace WatchIt.Website.Components.Pages.MediaPage.Panels; + +public partial class MediaActorRolesPanelComponent : ComponentBase +{ + #region SERVICES + + [Inject] private IMediaWebAPIService MediaWebAPIService { get; set; } = default!; + [Inject] private IPersonsWebAPIService PersonsWebAPIService { get; set; } = default!; + [Inject] private IRolesWebAPIService RolesWebAPIService { get; set; } = default!; + + #endregion + + + + #region PARAMETERS + + [Parameter] public string Class { get; set; } = string.Empty; + [Parameter] public required long Id { get; set; } + + #endregion +} \ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Components/Pages/MediaPage/Panels/MediaCreatorRolesPanelComponent.razor b/WatchIt.Website/WatchIt.Website/Components/Pages/MediaPage/Panels/MediaCreatorRolesPanelComponent.razor new file mode 100644 index 0000000..3361227 --- /dev/null +++ b/WatchIt.Website/WatchIt.Website/Components/Pages/MediaPage/Panels/MediaCreatorRolesPanelComponent.razor @@ -0,0 +1,42 @@ +@using WatchIt.Common.Model.Persons +@using WatchIt.Common.Model.Roles + + + +
+ @if (_loaded) + { +
+ Creators +
+ + @foreach (RoleTypeResponse roleType in _roleTypes) + { + @roleType.Name + } + +
+ +
+ } + else + { + + } +
\ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Components/Pages/MediaPage/Panels/MediaCreatorRolesPanelComponent.razor.cs b/WatchIt.Website/WatchIt.Website/Components/Pages/MediaPage/Panels/MediaCreatorRolesPanelComponent.razor.cs new file mode 100644 index 0000000..c1bb1b4 --- /dev/null +++ b/WatchIt.Website/WatchIt.Website/Components/Pages/MediaPage/Panels/MediaCreatorRolesPanelComponent.razor.cs @@ -0,0 +1,76 @@ +using Microsoft.AspNetCore.Components; +using WatchIt.Common.Model.Persons; +using WatchIt.Common.Model.Roles; +using WatchIt.Website.Components.Common.Subcomponents; +using WatchIt.Website.Services.Utility.Authentication; +using WatchIt.Website.Services.WebAPI.Media; +using WatchIt.Website.Services.WebAPI.Persons; +using WatchIt.Website.Services.WebAPI.Roles; + +namespace WatchIt.Website.Components.Pages.MediaPage.Panels; + +public partial class MediaCreatorRolesPanelComponent : ComponentBase +{ + #region SERVICES + + [Inject] private IPersonsWebAPIService PersonsWebAPIService { get; set; } = default!; + [Inject] private IMediaWebAPIService MediaWebAPIService { get; set; } = default!; + [Inject] private IRolesWebAPIService RolesWebAPIService { get; set; } = default!; + + #endregion + + + + #region PARAMETERS + + [Parameter] public string Class { get; set; } = string.Empty; + [Parameter] public required long Id { get; set; } + + #endregion + + + + #region FIELDS + + private RoleListComponent _roleListComponent; + + private bool _loaded; + + private IEnumerable _roleTypes; + private CreatorRoleMediaQueryParameters _query; + + #endregion + + + + #region PRIVATE METHODS + + protected override async Task OnAfterRenderAsync(bool firstRender) + { + if (firstRender) + { + List endTasks = new List(); + + // STEP 0 + endTasks.AddRange( + [ + RolesWebAPIService.GetAllCreatorRoleTypes(successAction: data => _roleTypes = data) + ]); + + // END + await Task.WhenAll(endTasks); + _query = new CreatorRoleMediaQueryParameters { TypeId = _roleTypes.First().Id }; + + _loaded = true; + StateHasChanged(); + } + } + + private async Task CheckedTypeChanged(short value) + { + _query.TypeId = value; + await _roleListComponent.Refresh(); + } + + #endregion +} \ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Components/Pages/PersonEditPage/Panels/PersonActorRolesEditPanelComponent.razor b/WatchIt.Website/WatchIt.Website/Components/Pages/PersonEditPage/Panels/PersonActorRolesEditPanelComponent.razor new file mode 100644 index 0000000..524fc31 --- /dev/null +++ b/WatchIt.Website/WatchIt.Website/Components/Pages/PersonEditPage/Panels/PersonActorRolesEditPanelComponent.razor @@ -0,0 +1,161 @@ +@using Blazorise.Extensions +@using WatchIt.Common.Model.Roles +@using Blazorise.Components + + + +
+ @if (_loaded) + { +
+
+
+
+

Actor roles

+
+ @if (!_editingMode) + { +
+ +
+ } + else + { + if (!string.IsNullOrWhiteSpace(_error)) + { +
+ @(_error) +
+ } +
+ +
+
+ +
+ } +
+
+ @if (!_editingMode) + { + if (_roles.IsNullOrEmpty()) + { + No items + } + else + { + + + + + + + + + + + + @foreach (Guid roleId in _roles.Keys) + { + + + + + + + + } + +
+ Media name + + Media type + + Role type + + Role name + + Actions +
+ @(Media[_roles[roleId].Data.MediaId].Title)@(Media[_roles[roleId].Data.MediaId].ReleaseDate.HasValue ? $" ({Media[_roles[roleId].Data.MediaId].ReleaseDate!.Value.Year})" : string.Empty) + + @(Media[_roles[roleId].Data.MediaId].Type == MediaType.Movie ? $"Movie" : "TV Series") + + @(_roleTypes[_roles[roleId].Data.TypeId]) + + @(_roles[roleId].Data.Name) + +
+ + +
+
+ } + } + else + { + + +
+
+ +
+ + Sorry... @not_found_context was not found + +
+
+
+ +
+ + @foreach (KeyValuePair type in _roleTypes) + { + + } + +
+
+
+ +
+ +
+
+
+
+ } +
+ } + else + { + + } +
\ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Components/Pages/PersonEditPage/Panels/PersonActorRolesEditPanelComponent.razor.cs b/WatchIt.Website/WatchIt.Website/Components/Pages/PersonEditPage/Panels/PersonActorRolesEditPanelComponent.razor.cs new file mode 100644 index 0000000..b462c9e --- /dev/null +++ b/WatchIt.Website/WatchIt.Website/Components/Pages/PersonEditPage/Panels/PersonActorRolesEditPanelComponent.razor.cs @@ -0,0 +1,150 @@ +using Microsoft.AspNetCore.Components; +using WatchIt.Common.Model.Media; +using WatchIt.Common.Model.Roles; +using WatchIt.Website.Services.WebAPI.Media; +using WatchIt.Website.Services.WebAPI.Persons; +using WatchIt.Website.Services.WebAPI.Roles; + +namespace WatchIt.Website.Components.Pages.PersonEditPage.Panels; + +public partial class PersonActorRolesEditPanelComponent : ComponentBase +{ + #region SERVICES + + [Inject] private IPersonsWebAPIService PersonsWebAPIService { get; set; } = default!; + [Inject] private IMediaWebAPIService MediaWebAPIService { get; set; } = default!; + [Inject] private IRolesWebAPIService RolesWebAPIService { get; set; } = default!; + + #endregion + + + + #region PARAMETERS + + [Parameter] public required long? Id { get; set; } + [Parameter] public required Dictionary Media { get; set; } + [Parameter] public string Class { get; set; } = string.Empty; + + #endregion + + + + #region FIELDS + + private bool _loaded; + private string? _error; + + private Dictionary _roles = []; + private Dictionary _roleTypes = []; + + + private Guid? _editedId; + private IActorRolePersonRequest? _editedModel; + + private bool _editingMode; + private bool _saving; + + #endregion + + + + #region PUBLIC METHODS + + protected override async Task OnAfterRenderAsync(bool firstRender) + { + if (firstRender) + { + List endTasks = new List(); + + // STEP 0 + if (Id.HasValue) + { + endTasks.AddRange( + [ + PersonsWebAPIService.GetPersonAllActorRoles(Id.Value, successAction: data => _roles = data.ToDictionary(x => x.Id, x => (x, false))), + RolesWebAPIService.GetAllActorRoleTypes(successAction: data => _roleTypes = data.ToDictionary(x => x.Id, x => x.Name)), + ]); + } + + // END + await Task.WhenAll(endTasks); + _roles = _roles.OrderBy(x => Media.First(y => y.Key == x.Value.Data.MediaId).Value.ReleaseDate).ToDictionary(x => x.Key, x => x.Value); + + _loaded = true; + StateHasChanged(); + } + } + + private void CancelEdit() + { + _error = null; + _editingMode = false; + } + + private async Task SaveEdit() + { + void SuccessPost(ActorRoleResponse data) + { + _roles[data.Id] = (data, false); + _roles = _roles.OrderBy(x => Media.First(y => y.Key == x.Value.Data.MediaId).Value.ReleaseDate).ToDictionary(x => x.Key, x => x.Value); + + _saving = false; + _editingMode = false; + } + + void SuccessPut() + { + ActorRoleResponse temp = _roles[_editedId!.Value].Data; + temp.MediaId = _editedModel.MediaId; + temp.TypeId = _editedModel.TypeId; + temp.Name = _editedModel.Name; + + _roles[_editedId!.Value] = (temp, false); + _roles = _roles.OrderBy(x => Media.First(y => y.Key == x.Value.Data.MediaId).Value.ReleaseDate).ToDictionary(x => x.Key, x => x.Value); + + _saving = false; + _editingMode = false; + } + + void BadRequest(IDictionary errors) + { + _error = errors.SelectMany(x => x.Value).FirstOrDefault() ?? "Unknown error"; + _saving = false; + } + + void Unauthorized() + { + _error = "You do not have permission to do this"; + _saving = false; + } + + _error = null; + _saving = true; + if (_editedId.HasValue) + { + await RolesWebAPIService.PutActorRole(_editedId.Value, _editedModel as ActorRoleUniversalRequest, SuccessPut, BadRequest, Unauthorized); + } + else + { + await PersonsWebAPIService.PostPersonActorRole(Id!.Value, _editedModel as ActorRolePersonRequest, SuccessPost, BadRequest, Unauthorized); + } + } + + private void ActivateEdit(Guid? id = null) + { + _editedId = id; + _editedModel = id.HasValue ? new ActorRoleUniversalRequest(_roles[id.Value].Data) : new ActorRolePersonRequest() + { + TypeId = _roleTypes.Keys.First() + }; + _editingMode = true; + } + + private async Task Delete(Guid id) + { + _roles[id] = (_roles[id].Data, true); + await RolesWebAPIService.DeleteActorRole(id, () => _roles.Remove(id)); + } + + #endregion +} \ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Components/Pages/PersonEditPage/Panels/PersonCreatorRolesEditPanelComponent.razor b/WatchIt.Website/WatchIt.Website/Components/Pages/PersonEditPage/Panels/PersonCreatorRolesEditPanelComponent.razor new file mode 100644 index 0000000..b952aae --- /dev/null +++ b/WatchIt.Website/WatchIt.Website/Components/Pages/PersonEditPage/Panels/PersonCreatorRolesEditPanelComponent.razor @@ -0,0 +1,148 @@ +@using Blazorise.Extensions +@using Blazorise.Components + + + +
+ @if (_loaded) + { +
+
+
+
+

Creator roles

+
+ @if (!_editingMode) + { +
+ +
+ } + else + { + if (!string.IsNullOrWhiteSpace(_error)) + { +
+ @(_error) +
+ } +
+ +
+
+ +
+ } +
+
+ @if (!_editingMode) + { + if (_roles.IsNullOrEmpty()) + { + No items + } + else + { + + + + + + + + + + + @foreach (Guid roleId in _roles.Keys) + { + + + + + + + } + +
+ Media name + + Media type + + Role type + + Actions +
+ @(Media[_roles[roleId].Data.MediaId].Title)@(Media[_roles[roleId].Data.MediaId].ReleaseDate.HasValue ? $" ({Media[_roles[roleId].Data.MediaId].ReleaseDate!.Value.Year})" : string.Empty) + + @(Media[_roles[roleId].Data.MediaId].Type == MediaType.Movie ? $"Movie" : "TV Series") + + @(_roleTypes[_roles[roleId].Data.TypeId]) + +
+ + +
+
+ } + } + else + { + + +
+
+ +
+ + Sorry... @not_found_context was not found + +
+
+
+ +
+ + @foreach (KeyValuePair type in _roleTypes) + { + + } + +
+
+
+
+ } +
+ } + else + { + + } +
\ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Components/Pages/PersonEditPage/Panels/PersonCreatorRolesEditPanelComponent.razor.cs b/WatchIt.Website/WatchIt.Website/Components/Pages/PersonEditPage/Panels/PersonCreatorRolesEditPanelComponent.razor.cs new file mode 100644 index 0000000..ca9b0c6 --- /dev/null +++ b/WatchIt.Website/WatchIt.Website/Components/Pages/PersonEditPage/Panels/PersonCreatorRolesEditPanelComponent.razor.cs @@ -0,0 +1,149 @@ +using Microsoft.AspNetCore.Components; +using WatchIt.Common.Model.Media; +using WatchIt.Common.Model.Roles; +using WatchIt.Website.Services.WebAPI.Media; +using WatchIt.Website.Services.WebAPI.Persons; +using WatchIt.Website.Services.WebAPI.Roles; + +namespace WatchIt.Website.Components.Pages.PersonEditPage.Panels; + +public partial class PersonCreatorRolesEditPanelComponent : ComponentBase +{ + #region SERVICES + + [Inject] private IPersonsWebAPIService PersonsWebAPIService { get; set; } = default!; + [Inject] private IMediaWebAPIService MediaWebAPIService { get; set; } = default!; + [Inject] private IRolesWebAPIService RolesWebAPIService { get; set; } = default!; + + #endregion + + + + #region PARAMETERS + + [Parameter] public required long? Id { get; set; } + [Parameter] public required Dictionary Media { get; set; } + [Parameter] public string Class { get; set; } = string.Empty; + + #endregion + + + + #region FIELDS + + private bool _loaded; + private string? _error; + + private Dictionary _roles = []; + private Dictionary _roleTypes = []; + + + private Guid? _editedId; + private ICreatorRolePersonRequest? _editedModel; + + private bool _editingMode; + private bool _saving; + + #endregion + + + + #region PUBLIC METHODS + + protected override async Task OnAfterRenderAsync(bool firstRender) + { + if (firstRender) + { + List endTasks = new List(); + + // STEP 0 + if (Id.HasValue) + { + endTasks.AddRange( + [ + PersonsWebAPIService.GetPersonAllCreatorRoles(Id.Value, successAction: data => _roles = data.ToDictionary(x => x.Id, x => (x, false))), + RolesWebAPIService.GetAllCreatorRoleTypes(successAction: data => _roleTypes = data.ToDictionary(x => x.Id, x => x.Name)), + ]); + } + + // END + await Task.WhenAll(endTasks); + _roles = _roles.OrderBy(x => Media.First(y => y.Key == x.Value.Data.MediaId).Value.ReleaseDate).ToDictionary(x => x.Key, x => x.Value); + + _loaded = true; + StateHasChanged(); + } + } + + private void CancelEdit() + { + _error = null; + _editingMode = false; + } + + private async Task SaveEdit() + { + void SuccessPost(CreatorRoleResponse data) + { + _roles[data.Id] = (data, false); + _roles = _roles.OrderBy(x => Media.First(y => y.Key == x.Value.Data.MediaId).Value.ReleaseDate).ToDictionary(x => x.Key, x => x.Value); + + _saving = false; + _editingMode = false; + } + + void SuccessPut() + { + CreatorRoleResponse temp = _roles[_editedId!.Value].Data; + temp.MediaId = _editedModel.MediaId; + temp.TypeId = _editedModel.TypeId; + + _roles[_editedId!.Value] = (temp, false); + _roles = _roles.OrderBy(x => Media.First(y => y.Key == x.Value.Data.MediaId).Value.ReleaseDate).ToDictionary(x => x.Key, x => x.Value); + + _saving = false; + _editingMode = false; + } + + void BadRequest(IDictionary errors) + { + _error = errors.SelectMany(x => x.Value).FirstOrDefault() ?? "Unknown error"; + _saving = false; + } + + void Unauthorized() + { + _error = "You do not have permission to do this"; + _saving = false; + } + + _error = null; + _saving = true; + if (_editedId.HasValue) + { + await RolesWebAPIService.PutCreatorRole(_editedId.Value, _editedModel as CreatorRoleUniversalRequest, SuccessPut, BadRequest, Unauthorized); + } + else + { + await PersonsWebAPIService.PostPersonCreatorRole(Id!.Value, _editedModel as CreatorRolePersonRequest, SuccessPost, BadRequest, Unauthorized); + } + } + + private void ActivateEdit(Guid? id = null) + { + _editedId = id; + _editedModel = id.HasValue ? new CreatorRoleUniversalRequest(_roles[id.Value].Data) : new CreatorRolePersonRequest() + { + TypeId = _roleTypes.Keys.First() + }; + _editingMode = true; + } + + private async Task Delete(Guid id) + { + _roles[id] = (_roles[id].Data, true); + await RolesWebAPIService.DeleteCreatorRole(id, () => _roles.Remove(id)); + } + + #endregion +} \ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Components/Pages/PersonEditPage/Panels/PersonEditFormPanelComponent.razor b/WatchIt.Website/WatchIt.Website/Components/Pages/PersonEditPage/Panels/PersonEditFormPanelComponent.razor new file mode 100644 index 0000000..949134c --- /dev/null +++ b/WatchIt.Website/WatchIt.Website/Components/Pages/PersonEditPage/Panels/PersonEditFormPanelComponent.razor @@ -0,0 +1,79 @@ +@using WatchIt.Common.Model.Genders + + + +
+ @if (_loaded) + { + + +
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+
+ + - + +
+
+
+
+ +
+ + + @foreach (GenderResponse gender in _genders) + { + + } + +
+
+
+
+ @if (!string.IsNullOrWhiteSpace(_error)) + { + @(_error) + } +
+
+ +
+
+
+
+ } + else + { + + } +
\ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Components/Pages/PersonEditPage/Panels/PersonEditFormPanelComponent.razor.cs b/WatchIt.Website/WatchIt.Website/Components/Pages/PersonEditPage/Panels/PersonEditFormPanelComponent.razor.cs new file mode 100644 index 0000000..c76a9ff --- /dev/null +++ b/WatchIt.Website/WatchIt.Website/Components/Pages/PersonEditPage/Panels/PersonEditFormPanelComponent.razor.cs @@ -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.Pages.PersonEditPage.Panels; + +public partial class PersonEditFormPanelComponent : 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 _genders = []; + + private PersonRequest _person = new PersonRequest(); + + #endregion + + + + #region PRIVATE METHODS + + protected override async Task OnAfterRenderAsync(bool firstRender) + { + if (firstRender) + { + List endTasks = new List(); + + // 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", true); + } + + void BadRequest(IDictionary 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 +} \ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Components/Pages/PersonPage/Panels/PersonActorRolesPanelComponent.razor b/WatchIt.Website/WatchIt.Website/Components/Pages/PersonPage/Panels/PersonActorRolesPanelComponent.razor new file mode 100644 index 0000000..88a40e8 --- /dev/null +++ b/WatchIt.Website/WatchIt.Website/Components/Pages/PersonPage/Panels/PersonActorRolesPanelComponent.razor @@ -0,0 +1,27 @@ +@using WatchIt.Common.Model.Persons +@using WatchIt.Common.Model.Roles + + + +
+
+ Actor + +
+
\ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Components/Pages/PersonPage/Panels/PersonActorRolesPanelComponent.razor.cs b/WatchIt.Website/WatchIt.Website/Components/Pages/PersonPage/Panels/PersonActorRolesPanelComponent.razor.cs new file mode 100644 index 0000000..4b87639 --- /dev/null +++ b/WatchIt.Website/WatchIt.Website/Components/Pages/PersonPage/Panels/PersonActorRolesPanelComponent.razor.cs @@ -0,0 +1,27 @@ +using Microsoft.AspNetCore.Components; +using WatchIt.Website.Services.WebAPI.Media; +using WatchIt.Website.Services.WebAPI.Persons; +using WatchIt.Website.Services.WebAPI.Roles; + +namespace WatchIt.Website.Components.Pages.PersonPage.Panels; + +public partial class PersonActorRolesPanelComponent : ComponentBase +{ + #region SERVICES + + [Inject] private IMediaWebAPIService MediaWebAPIService { get; set; } = default!; + [Inject] private IPersonsWebAPIService PersonsWebAPIService { get; set; } = default!; + [Inject] private IRolesWebAPIService RolesWebAPIService { get; set; } = default!; + + #endregion + + + + #region PARAMETERS + + [Parameter] public string Class { get; set; } = string.Empty; + [Parameter] public required long Id { get; set; } + [Parameter] public Action? OnRatingChanged { get; set; } + + #endregion +} \ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Components/Pages/PersonPage/Panels/PersonCreatorRolesPanelComponent.razor b/WatchIt.Website/WatchIt.Website/Components/Pages/PersonPage/Panels/PersonCreatorRolesPanelComponent.razor new file mode 100644 index 0000000..609b18a --- /dev/null +++ b/WatchIt.Website/WatchIt.Website/Components/Pages/PersonPage/Panels/PersonCreatorRolesPanelComponent.razor @@ -0,0 +1,43 @@ +@using WatchIt.Common.Model.Persons +@using WatchIt.Common.Model.Roles + + + +
+ @if (_loaded) + { +
+ Creators +
+ + @foreach (RoleTypeResponse roleType in _roleTypes) + { + @roleType.Name + } + +
+ +
+ } + else + { + + } +
\ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Components/Pages/PersonPage/Panels/PersonCreatorRolesPanelComponent.razor.cs b/WatchIt.Website/WatchIt.Website/Components/Pages/PersonPage/Panels/PersonCreatorRolesPanelComponent.razor.cs new file mode 100644 index 0000000..ac6f353 --- /dev/null +++ b/WatchIt.Website/WatchIt.Website/Components/Pages/PersonPage/Panels/PersonCreatorRolesPanelComponent.razor.cs @@ -0,0 +1,76 @@ +using Microsoft.AspNetCore.Components; +using WatchIt.Common.Model.Media; +using WatchIt.Common.Model.Roles; +using WatchIt.Website.Components.Common.Subcomponents; +using WatchIt.Website.Services.WebAPI.Media; +using WatchIt.Website.Services.WebAPI.Persons; +using WatchIt.Website.Services.WebAPI.Roles; + +namespace WatchIt.Website.Components.Pages.PersonPage.Panels; + +public partial class PersonCreatorRolesPanelComponent : ComponentBase +{ + #region SERVICES + + [Inject] private IPersonsWebAPIService PersonsWebAPIService { get; set; } = default!; + [Inject] private IMediaWebAPIService MediaWebAPIService { get; set; } = default!; + [Inject] private IRolesWebAPIService RolesWebAPIService { get; set; } = default!; + + #endregion + + + + #region PARAMETERS + + [Parameter] public string Class { get; set; } = string.Empty; + [Parameter] public required long Id { get; set; } + [Parameter] public Action? OnRatingChanged { get; set; } + + #endregion + + + + #region FIELDS + + private RoleListComponent _roleListComponent; + + private bool _loaded; + + private IEnumerable _roleTypes; + private CreatorRolePersonQueryParameters _query; + + #endregion + + + + #region PRIVATE METHODS + + protected override async Task OnAfterRenderAsync(bool firstRender) + { + if (firstRender) + { + List endTasks = new List(); + + // STEP 0 + endTasks.AddRange( + [ + RolesWebAPIService.GetAllCreatorRoleTypes(successAction: data => _roleTypes = data) + ]); + + // END + await Task.WhenAll(endTasks); + _query = new CreatorRolePersonQueryParameters { TypeId = _roleTypes.First().Id }; + + _loaded = true; + StateHasChanged(); + } + } + + private async Task CheckedTypeChanged(short value) + { + _query.TypeId = value; + await _roleListComponent.Refresh(); + } + + #endregion +} \ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Components/Pages/PersonPage/Panels/PersonMetadataPanel.razor b/WatchIt.Website/WatchIt.Website/Components/Pages/PersonPage/Panels/PersonMetadataPanel.razor new file mode 100644 index 0000000..331fec5 --- /dev/null +++ b/WatchIt.Website/WatchIt.Website/Components/Pages/PersonPage/Panels/PersonMetadataPanel.razor @@ -0,0 +1,16 @@ +
+ +
\ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Components/Pages/PersonPage/Panels/PersonMetadataPanel.razor.cs b/WatchIt.Website/WatchIt.Website/Components/Pages/PersonPage/Panels/PersonMetadataPanel.razor.cs new file mode 100644 index 0000000..03abb8b --- /dev/null +++ b/WatchIt.Website/WatchIt.Website/Components/Pages/PersonPage/Panels/PersonMetadataPanel.razor.cs @@ -0,0 +1,13 @@ +using Microsoft.AspNetCore.Components; +using WatchIt.Common.Model.Persons; + +namespace WatchIt.Website.Components.Pages.PersonPage.Panels; + +public partial class PersonMetadataPanel : ComponentBase +{ + #region PARAMETERS + + [Parameter] public required PersonResponse Item { get; set; } + + #endregion +} \ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Components/Pages/PersonPage/Panels/PersonRatingPanel.razor b/WatchIt.Website/WatchIt.Website/Components/Pages/PersonPage/Panels/PersonRatingPanel.razor new file mode 100644 index 0000000..2490e0b --- /dev/null +++ b/WatchIt.Website/WatchIt.Website/Components/Pages/PersonPage/Panels/PersonRatingPanel.razor @@ -0,0 +1,17 @@ +
+
+ +
+ @if (_user is not null) + { + + } + else + { +
+

Your rating:

+ Log in to see your rating +
+ } +
+
\ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Components/Pages/PersonPage/Panels/PersonRatingPanel.razor.cs b/WatchIt.Website/WatchIt.Website/Components/Pages/PersonPage/Panels/PersonRatingPanel.razor.cs new file mode 100644 index 0000000..4e57c54 --- /dev/null +++ b/WatchIt.Website/WatchIt.Website/Components/Pages/PersonPage/Panels/PersonRatingPanel.razor.cs @@ -0,0 +1,97 @@ +using Microsoft.AspNetCore.Components; +using WatchIt.Common.Model.Rating; +using WatchIt.Website.Services.Utility.Authentication; +using WatchIt.Website.Services.WebAPI.Persons; + +namespace WatchIt.Website.Components.Pages.PersonPage.Panels; + +public partial class PersonRatingPanel : ComponentBase +{ + #region SERVICES + + [Inject] private IAuthenticationService AuthenticationService { get; set; } = default!; + [Inject] private IPersonsWebAPIService PersonsWebAPIService { get; set; } = default!; + + #endregion + + + + #region PARAMETERS + + [Parameter] public required long Id { get; set; } + [Parameter] public RatingResponse? Rating { get; set; } + + #endregion + + + + #region FIELDS + + private User? _user; + + private RatingResponse? _userRating; + + #endregion + + + + #region PUBLIC METHODS + + public async Task UpdateRating() + { + await Task.WhenAll(UpdateGlobalRating(), UpdateUserRating()); + StateHasChanged(); + } + + #endregion + + + + #region PRIVATE METHODS + + protected override async Task OnAfterRenderAsync(bool firstRender) + { + if (firstRender) + { + List step1Tasks = new List(1); + List endTasks = new List(2); + + // STEP 0 + step1Tasks.AddRange( + [ + Task.Run(async () => _user = await AuthenticationService.GetUserAsync()) + ]); + if (Rating is null) + { + endTasks.AddRange( + [ + UpdateGlobalRating() + ]); + } + + // STEP 1 + await Task.WhenAll(step1Tasks); + endTasks.AddRange( + [ + UpdateUserRating() + ]); + + // END + await Task.WhenAll(endTasks); + + StateHasChanged(); + } + } + + protected async Task UpdateGlobalRating() => await PersonsWebAPIService.GetPersonGlobalRating(Id, data => Rating = data); + + protected async Task UpdateUserRating() + { + if (_user is not null) + { + await PersonsWebAPIService.GetPersonUserRating(Id, _user.Id, data => _userRating = data); + } + } + + #endregion +} \ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Components/SearchPage/SearchResultComponent.razor b/WatchIt.Website/WatchIt.Website/Components/Pages/SearchPage/Panels/SearchResultPanelComponent.razor similarity index 60% rename from WatchIt.Website/WatchIt.Website/Components/SearchPage/SearchResultComponent.razor rename to WatchIt.Website/WatchIt.Website/Components/Pages/SearchPage/Panels/SearchResultPanelComponent.razor index a448ee8..c0a7d47 100644 --- a/WatchIt.Website/WatchIt.Website/Components/SearchPage/SearchResultComponent.razor +++ b/WatchIt.Website/WatchIt.Website/Components/Pages/SearchPage/Panels/SearchResultPanelComponent.razor @@ -5,7 +5,7 @@ -
+
@@ -28,13 +28,21 @@ }
- - - + @{ + int iCopy = i; + long id = IdSource(_items[iCopy]); + string url = string.Format(UrlIdTemplate, id); + } +
} @@ -74,7 +82,7 @@ {
- +
} diff --git a/WatchIt.Website/WatchIt.Website/Components/SearchPage/SearchResultComponent.razor.cs b/WatchIt.Website/WatchIt.Website/Components/Pages/SearchPage/Panels/SearchResultPanelComponent.razor.cs similarity index 79% rename from WatchIt.Website/WatchIt.Website/Components/SearchPage/SearchResultComponent.razor.cs rename to WatchIt.Website/WatchIt.Website/Components/Pages/SearchPage/Panels/SearchResultPanelComponent.razor.cs index 2e93844..e3f2f68 100644 --- a/WatchIt.Website/WatchIt.Website/Components/SearchPage/SearchResultComponent.razor.cs +++ b/WatchIt.Website/WatchIt.Website/Components/Pages/SearchPage/Panels/SearchResultPanelComponent.razor.cs @@ -3,19 +3,26 @@ using WatchIt.Common.Model; using WatchIt.Common.Model.Rating; using WatchIt.Common.Query; -namespace WatchIt.Website.Components.SearchPage; +namespace WatchIt.Website.Components.Pages.SearchPage.Panels; -public partial class SearchResultComponent : ComponentBase where TQuery : QueryParameters +public partial class SearchResultPanelComponent : ComponentBase where TQuery : QueryParameters { #region PARAMETERS [Parameter] public required string Title { get; set; } [Parameter] public required TQuery Query { get; set; } + [Parameter] public required Func IdSource { get; set; } [Parameter] public required Func NameSource { get; set; } [Parameter] public Func AdditionalNameInfoSource { get; set; } = _ => null; [Parameter] public required Func RatingSource { get; set; } + [Parameter] public required Func, Task> GetGlobalRatingMethod { get; set; } + [Parameter] public Func, Action, Task>? GetUserRatingMethod { get; set; } + [Parameter] public Func? PutRatingMethod { get; set; } + [Parameter] public Func? DeleteRatingMethod { get; set; } [Parameter] public required string UrlIdTemplate { get; set; } + [Parameter] public required string PosterPlaceholder { get; set; } + [Parameter] public required Func>, Task> ItemDownloadingTask { get; set; } [Parameter] public required Func, Task> PictureDownloadingTask { get; set; } diff --git a/WatchIt.Website/WatchIt.Website/Layout/MainLayout.razor b/WatchIt.Website/WatchIt.Website/Layout/MainLayout.razor index 6e23112..63f25b6 100644 --- a/WatchIt.Website/WatchIt.Website/Layout/MainLayout.razor +++ b/WatchIt.Website/WatchIt.Website/Layout/MainLayout.razor @@ -12,7 +12,7 @@
-
+
@@ -37,6 +37,7 @@ Movies TV Series + People diff --git a/WatchIt.Website/WatchIt.Website/Pages/AdminPage.razor b/WatchIt.Website/WatchIt.Website/Pages/AdminPage.razor index c13c42f..885be66 100644 --- a/WatchIt.Website/WatchIt.Website/Pages/AdminPage.razor +++ b/WatchIt.Website/WatchIt.Website/Pages/AdminPage.razor @@ -14,21 +14,21 @@
-

New movie

+

New movie

+
+ +

New TV series

+
+ +

New person

-
-

New TV series

-
-
-

New TV series

-
} else {
- +
} diff --git a/WatchIt.Website/WatchIt.Website/Pages/DatabasePage.razor b/WatchIt.Website/WatchIt.Website/Pages/DatabasePage.razor index 66a49ac..5740ae8 100644 --- a/WatchIt.Website/WatchIt.Website/Pages/DatabasePage.razor +++ b/WatchIt.Website/WatchIt.Website/Pages/DatabasePage.razor @@ -1,73 +1,107 @@ @using WatchIt.Common.Model.Movies +@using WatchIt.Common.Model.Persons @using WatchIt.Common.Model.Series -@using WatchIt.Website.Components.DatabasePage +@using WatchIt.Website.Components.Pages.DatabasePage +@using WatchIt.Website.Components.Pages.DatabasePage.Subcomponents @page "/database/{type?}" + @("WatchIt - ") @switch (Type) { - case "movies": @("Movies"); break; - case "series": @("Series"); break; + case "movies": + @("Movies"); + break; + case "series": + @("Series"); + break; + case "people": + @("People"); + break; } - @(" database - WatchIt") + @(" database") -@if (_loaded) + +@switch (Type) { - switch (Type) - { - case "movies": - - - - break; - case "series": - - - - break; - } - -} -else -{ -
- -
+ case "movies": + + + + break; + case "series": + + + + break; + case "people": + + + + break; } \ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Pages/DatabasePage.razor.cs b/WatchIt.Website/WatchIt.Website/Pages/DatabasePage.razor.cs index 186a3b7..179454a 100644 --- a/WatchIt.Website/WatchIt.Website/Pages/DatabasePage.razor.cs +++ b/WatchIt.Website/WatchIt.Website/Pages/DatabasePage.razor.cs @@ -1,7 +1,8 @@ using Microsoft.AspNetCore.Components; -using WatchIt.Website.Components.DatabasePage; +using WatchIt.Website.Layout; using WatchIt.Website.Services.WebAPI.Media; using WatchIt.Website.Services.WebAPI.Movies; +using WatchIt.Website.Services.WebAPI.Persons; using WatchIt.Website.Services.WebAPI.Series; namespace WatchIt.Website.Pages; @@ -14,6 +15,7 @@ public partial class DatabasePage : ComponentBase [Inject] private IMediaWebAPIService MediaWebAPIService { get; set; } = default!; [Inject] private IMoviesWebAPIService MoviesWebAPIService { get; set; } = default!; [Inject] private ISeriesWebAPIService SeriesWebAPIService { get; set; } = default!; + [Inject] private IPersonsWebAPIService PersonsWebAPIService { get; set; } = default!; #endregion @@ -23,15 +25,15 @@ public partial class DatabasePage : ComponentBase [Parameter] public string? Type { get; set; } + [CascadingParameter] public MainLayout Layout { get; set; } + #endregion #region FIELDS - private static IEnumerable _databaseTypes = ["movies", "series"]; - - private bool _loaded; + private static IEnumerable _databaseTypes = ["movies", "series", "people"]; #endregion @@ -39,17 +41,21 @@ public partial class DatabasePage : ComponentBase #region PRIVATE METHODS - protected override async Task OnAfterRenderAsync(bool firstRender) + protected override void OnParametersSet() + { + if (!_databaseTypes.Contains(Type)) + { + NavigationManager.NavigateTo($"/database/{_databaseTypes.First()}"); + } + } + + protected override void OnAfterRender(bool firstRender) { if (firstRender) { // INIT - if (!_databaseTypes.Contains(Type)) - { - NavigationManager.NavigateTo($"/database/{_databaseTypes.First()}"); - } + Layout.BackgroundPhoto = null; - _loaded = true; StateHasChanged(); } } diff --git a/WatchIt.Website/WatchIt.Website/Pages/HomePage.razor b/WatchIt.Website/WatchIt.Website/Pages/HomePage.razor index 1766091..f967910 100644 --- a/WatchIt.Website/WatchIt.Website/Pages/HomePage.razor +++ b/WatchIt.Website/WatchIt.Website/Pages/HomePage.razor @@ -1,106 +1,37 @@ -@page "/" +@using WatchIt.Common.Model.Movies +@using WatchIt.Common.Model.Persons +@using WatchIt.Common.Model.Series +@using WatchIt.Website.Components.Pages.HomePage.Panels + +@page "/" WatchIt -
- @if (_loaded) - { - if (string.IsNullOrWhiteSpace(_error)) - { -
-
-
-
-
-
-

Top 5 movies this week by popularity

-
-
- -
-
-
-
-
-
-
-
-
-
-

Top 5 TV series this week by popularity

-
-
- -
-
-
-
- } - else - { -
-
- -
-
- } - } - else - { -
-
-
- -
-
-
- } + + +
+ + +
\ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Pages/HomePage.razor.cs b/WatchIt.Website/WatchIt.Website/Pages/HomePage.razor.cs index 5f528db..abed50c 100644 --- a/WatchIt.Website/WatchIt.Website/Pages/HomePage.razor.cs +++ b/WatchIt.Website/WatchIt.Website/Pages/HomePage.razor.cs @@ -5,6 +5,7 @@ using WatchIt.Common.Model.Series; using WatchIt.Website.Layout; using WatchIt.Website.Services.WebAPI.Media; using WatchIt.Website.Services.WebAPI.Movies; +using WatchIt.Website.Services.WebAPI.Persons; using WatchIt.Website.Services.WebAPI.Series; namespace WatchIt.Website.Pages; @@ -17,26 +18,15 @@ public partial class HomePage [Inject] public IMediaWebAPIService MediaWebAPIService { get; set; } = default!; [Inject] public IMoviesWebAPIService MoviesWebAPIService { get; set; } = default!; [Inject] public ISeriesWebAPIService SeriesWebAPIService { get; set; } = default!; + [Inject] public IPersonsWebAPIService PersonsWebAPIService { get; set; } = default!; #endregion #region PARAMETERS - - [CascadingParameter] public MainLayout Layout { get; set; } - - #endregion - - - - #region FIELDS - - private bool _loaded; - private string? _error; - - private IDictionary _topMovies = new Dictionary(); - private IDictionary _topSeries = new Dictionary(); + + [CascadingParameter] public MainLayout Layout { get; set; } = default!; #endregion @@ -44,34 +34,12 @@ public partial class HomePage #region PRIVATE METHODS - protected override async Task OnAfterRenderAsync(bool firstRender) + protected override void OnAfterRender(bool firstRender) { if (firstRender) { Layout.BackgroundPhoto = null; - List step1Tasks = new List(); - List endTasks = new List(); - - // STEP 0 - step1Tasks.AddRange( - [ - MoviesWebAPIService.GetMoviesViewRank(successAction: data => _topMovies = data.ToDictionary(x => x, _ => default(MediaPosterResponse?))), - SeriesWebAPIService.GetSeriesViewRank(successAction: data => _topSeries = data.ToDictionary(x => x, _ => default(MediaPosterResponse?))), - ]); - - // STEP 1 - await Task.WhenAll(step1Tasks); - endTasks.AddRange( - [ - Parallel.ForEachAsync(_topMovies, async (x, _) => await MediaWebAPIService.GetMediaPoster(x.Key.Id, y => _topMovies[x.Key] = y)), - Parallel.ForEachAsync(_topSeries, async (x, _) => await MediaWebAPIService.GetMediaPoster(x.Key.Id, y => _topSeries[x.Key] = y)) - ]); - - // END - await Task.WhenAll(endTasks); - - _loaded = true; StateHasChanged(); } } diff --git a/WatchIt.Website/WatchIt.Website/Pages/HomePage.razor.css b/WatchIt.Website/WatchIt.Website/Pages/HomePage.razor.css index 2b6a9bf..e69de29 100644 --- a/WatchIt.Website/WatchIt.Website/Pages/HomePage.razor.css +++ b/WatchIt.Website/WatchIt.Website/Pages/HomePage.razor.css @@ -1,16 +0,0 @@ -/* CLASSES */ - -.poster-aspect-ratio { - aspect-ratio: 3/5; -} - -.border-2 { - border-width: 2px; -} - -.place-circle { - width: 30px; - height: 30px; - vertical-align: middle; - line-height: 25px; -} \ 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 68b0d51..58a4ef7 100644 --- a/WatchIt.Website/WatchIt.Website/Pages/MediaEditPage.razor +++ b/WatchIt.Website/WatchIt.Website/Pages/MediaEditPage.razor @@ -2,6 +2,7 @@ @using WatchIt.Common.Model.Movies @using WatchIt.Common.Model.Photos @using WatchIt.Common.Model.Series +@using WatchIt.Website.Components.Pages.MediaEditPage.Panels @page "/media/{id:long}/edit" @page "/media/new/{type?}" @@ -56,60 +57,12 @@
-
-
-
-
- poster -
-
-
-
- -
-
- @if (_mediaPosterChanged || _mediaPosterSaved is not null) - { -
- @if (_mediaPosterChanged) - { -
- -
-
- -
- } - else if (_mediaPosterSaved is not null) - { -
- -
- } -
- } -
-
+
@@ -199,6 +152,18 @@
+
+
+ +
+
+
+
+ +
+
@@ -251,7 +216,7 @@
- photo +
@@ -307,7 +272,7 @@
- edit_photo +
@if (_photoEditId is null) @@ -364,7 +329,7 @@ {
- +
} @@ -373,7 +338,7 @@ {
- +
} diff --git a/WatchIt.Website/WatchIt.Website/Pages/MediaEditPage.razor.cs b/WatchIt.Website/WatchIt.Website/Pages/MediaEditPage.razor.cs index e034282..d0dc6f5 100644 --- a/WatchIt.Website/WatchIt.Website/Pages/MediaEditPage.razor.cs +++ b/WatchIt.Website/WatchIt.Website/Pages/MediaEditPage.razor.cs @@ -3,12 +3,14 @@ using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Forms; using WatchIt.Common.Model.Media; using WatchIt.Common.Model.Movies; +using WatchIt.Common.Model.Persons; using WatchIt.Common.Model.Photos; using WatchIt.Common.Model.Series; using WatchIt.Website.Layout; using WatchIt.Website.Services.Utility.Authentication; using WatchIt.Website.Services.WebAPI.Media; using WatchIt.Website.Services.WebAPI.Movies; +using WatchIt.Website.Services.WebAPI.Persons; using WatchIt.Website.Services.WebAPI.Photos; using WatchIt.Website.Services.WebAPI.Series; @@ -24,6 +26,7 @@ public partial class MediaEditPage : ComponentBase [Inject] public IMoviesWebAPIService MoviesWebAPIService { get; set; } = default!; [Inject] public ISeriesWebAPIService SeriesWebAPIService { get; set; } = default!; [Inject] public IPhotosWebAPIService PhotosWebAPIService { get; set; } = default!; + [Inject] public IPersonsWebAPIService PersonsWebAPIService { get; set; } = default!; #endregion @@ -48,6 +51,8 @@ public partial class MediaEditPage : ComponentBase private User? _user; private MediaResponse? _media; + private Dictionary _persons; + private MovieRequest? _movieRequest; private SeriesRequest? _seriesRequest; private Media? _mediaRequest => _movieRequest is not null ? _movieRequest : _seriesRequest; @@ -107,6 +112,10 @@ public partial class MediaEditPage : ComponentBase [ InitializeMedia() ]); + endTasks.AddRange( + [ + PersonsWebAPIService.GetAllPersons(successAction: data => _persons = data.ToDictionary(x => x.Id, x => x)) + ]); } // STEP 2 diff --git a/WatchIt.Website/WatchIt.Website/Pages/MediaPage.razor b/WatchIt.Website/WatchIt.Website/Pages/MediaPage.razor index 6c144cc..2dde4a8 100644 --- a/WatchIt.Website/WatchIt.Website/Pages/MediaPage.razor +++ b/WatchIt.Website/WatchIt.Website/Pages/MediaPage.razor @@ -1,6 +1,7 @@ @using System.Text @using Microsoft.IdentityModel.Tokens @using WatchIt.Common.Model.Genres +@using WatchIt.Website.Components.Pages.MediaPage.Panels @page "/media/{id:long}" @@ -29,50 +30,25 @@ else { if (string.IsNullOrWhiteSpace(_error)) { -
-
- poster -
+
-
-
-
-
-

- @_media.Title -

-
-
- @if (!string.IsNullOrWhiteSpace(_media.Description)) - { -
-
-
- @_media.Description -
-
-
- } -
-
+
-
+
-
+
-
+
-

- Global rating: @(_globalRating.Count == 0 ? "no ratings" : $"{Math.Round(_globalRating.Average, 1)}/10") -

+
@@ -190,12 +164,37 @@ else
+
+
+ + + Actors + Creators + + + +
+ +
+
+ +
+ +
+
+
+
+
+
} else {
- +
} diff --git a/WatchIt.Website/WatchIt.Website/Pages/MediaPage.razor.cs b/WatchIt.Website/WatchIt.Website/Pages/MediaPage.razor.cs index fb48fd0..e3321c9 100644 --- a/WatchIt.Website/WatchIt.Website/Pages/MediaPage.razor.cs +++ b/WatchIt.Website/WatchIt.Website/Pages/MediaPage.razor.cs @@ -90,7 +90,6 @@ public partial class MediaPage : ComponentBase [ MediaWebAPIService.PostMediaView(Id), MediaWebAPIService.GetMediaPhotoRandomBackground(Id, data => Layout.BackgroundPhoto = data), - MediaWebAPIService.GetMediaPoster(Id, data => _poster = data), MediaWebAPIService.GetMediaGenres(Id, data => _genres = data), MediaWebAPIService.GetMediaRating(Id, data => _globalRating = data), _media.Type == MediaType.Movie ? MoviesWebAPIService.GetMovie(Id, data => _movie = data) : SeriesWebAPIService.GetSeries(Id, data => _series = data), diff --git a/WatchIt.Website/WatchIt.Website/Pages/PersonEditPage.razor b/WatchIt.Website/WatchIt.Website/Pages/PersonEditPage.razor new file mode 100644 index 0000000..4e557d3 --- /dev/null +++ b/WatchIt.Website/WatchIt.Website/Pages/PersonEditPage.razor @@ -0,0 +1,87 @@ +@using WatchIt.Common.Model.Persons +@using WatchIt.Website.Components.Pages.PersonEditPage.Panels + +@page "/person/{id:long}/edit" +@page "/person/new" + + + + + 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") + } + + + + +@if (_loaded) +{ + if (_user?.IsAdmin == true) + { +
+
+
+
+

@(Id is not null ? "Edit" : "Create new") person @(_person is not null ? $" \"{_person.Name}\"" : string.Empty)

+
+
+
+
+
+ +
+
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+ } + else + { + + } +} +else +{ +
+ +
+} diff --git a/WatchIt.Website/WatchIt.Website/Pages/PersonEditPage.razor.cs b/WatchIt.Website/WatchIt.Website/Pages/PersonEditPage.razor.cs new file mode 100644 index 0000000..242d128 --- /dev/null +++ b/WatchIt.Website/WatchIt.Website/Pages/PersonEditPage.razor.cs @@ -0,0 +1,83 @@ +using Microsoft.AspNetCore.Components; +using WatchIt.Common.Model.Media; +using WatchIt.Common.Model.Persons; +using WatchIt.Website.Layout; +using WatchIt.Website.Services.Utility.Authentication; +using WatchIt.Website.Services.WebAPI.Media; +using WatchIt.Website.Services.WebAPI.Persons; + +namespace WatchIt.Website.Pages; + +public partial class PersonEditPage : ComponentBase +{ + #region SERVICES + + [Inject] private NavigationManager NavigationManager { get; set; } = default!; + [Inject] private IAuthenticationService AuthenticationService { get; set; } = default!; + [Inject] private IPersonsWebAPIService PersonsWebAPIService { get; set; } = default!; + [Inject] private IMediaWebAPIService MediaWebAPIService { get; set; } = default!; + + #endregion + + + + #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; + private Dictionary _media = []; + + #endregion + + + + #region PRIVATE METHODS + + protected override async Task OnAfterRenderAsync(bool firstRender) + { + if (firstRender) + { + List step1Tasks = new List(); + List endTasks = new List(); + + // 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, () => NavigationManager.NavigateTo("/person/new", true)), + MediaWebAPIService.GetAllMedia(successAction: data => _media = data.ToDictionary(x => x.Id, x => x)), + ]); + } + + // END + await Task.WhenAll(endTasks); + + _loaded = true; + StateHasChanged(); + } + } + + #endregion +} \ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Components/DatabasePage/DatabasePageComponent.razor.css b/WatchIt.Website/WatchIt.Website/Pages/PersonEditPage.razor.css similarity index 100% rename from WatchIt.Website/WatchIt.Website/Components/DatabasePage/DatabasePageComponent.razor.css rename to WatchIt.Website/WatchIt.Website/Pages/PersonEditPage.razor.css diff --git a/WatchIt.Website/WatchIt.Website/Pages/PersonPage.razor b/WatchIt.Website/WatchIt.Website/Pages/PersonPage.razor new file mode 100644 index 0000000..d88eb16 --- /dev/null +++ b/WatchIt.Website/WatchIt.Website/Pages/PersonPage.razor @@ -0,0 +1,89 @@ +@using System.Text +@using WatchIt.Website.Components.Pages.PersonPage.Panels + +@page "/person/{id:long}" + +@{ + StringBuilder sb = new StringBuilder(" - WatchIt"); + + if (!_loaded) sb.Insert(0, "Loading..."); + else if (_person is null) sb.Insert(0, "Error"); + else sb.Insert(0, _person.Name); + + @(sb.ToString()) +} + + + +
+ @if (_loaded) + { + if (_person is not null) + { +
+
+ +
+
+
+
+ +
+
+ +
+
+
+
+ + + Actor + Creator + + + +
+ +
+
+ +
+ +
+
+
+
+
+
+ } + else + { +
+
+ +
+
+ } + } + else + { +
+
+
+ +
+
+
+ } +
\ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Pages/PersonPage.razor.cs b/WatchIt.Website/WatchIt.Website/Pages/PersonPage.razor.cs new file mode 100644 index 0000000..12120a1 --- /dev/null +++ b/WatchIt.Website/WatchIt.Website/Pages/PersonPage.razor.cs @@ -0,0 +1,78 @@ +using Microsoft.AspNetCore.Components; +using WatchIt.Common.Model.Persons; +using WatchIt.Website.Components.Pages.PersonPage.Panels; +using WatchIt.Website.Layout; +using WatchIt.Website.Services.WebAPI.Persons; + +namespace WatchIt.Website.Pages; + +public partial class PersonPage : ComponentBase +{ + #region SERVICES + + [Inject] private IPersonsWebAPIService PersonsWebAPIService { get; set; } = default!; + + #endregion + + + + #region PARAMETERS + + [Parameter] public long Id { get; set; } + + [CascadingParameter] public MainLayout Layout { get; set; } = default!; + + #endregion + + + + #region FIELDS + + private bool _loaded; + + private PersonRatingPanel _ratingPanel = default!; + + private PersonResponse? _person; + + #endregion + + + + #region PRIVATE METHODS + + protected override async Task OnAfterRenderAsync(bool firstRender) + { + if (firstRender) + { + // INIT + Layout.BackgroundPhoto = null; + + List step1Tasks = new List(1); + List endTasks = new List(1); + + // STEP 0 + step1Tasks.AddRange( + [ + PersonsWebAPIService.GetPerson(Id, data => _person = data) + ]); + + // STEP 1 + await Task.WhenAll(step1Tasks); + if (_person is not null) + { + endTasks.AddRange( + [ + PersonsWebAPIService.PostPersonView(Id), + ]); + } + + // END + await Task.WhenAll(endTasks); + + _loaded = true; + StateHasChanged(); + } + } + + #endregion +} \ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Components/SearchPage/SearchResultComponent.razor.css b/WatchIt.Website/WatchIt.Website/Pages/PersonPage.razor.css similarity index 100% rename from WatchIt.Website/WatchIt.Website/Components/SearchPage/SearchResultComponent.razor.css rename to WatchIt.Website/WatchIt.Website/Pages/PersonPage.razor.css diff --git a/WatchIt.Website/WatchIt.Website/Pages/SearchPage.razor b/WatchIt.Website/WatchIt.Website/Pages/SearchPage.razor index c0bb6e3..a88e28e 100644 --- a/WatchIt.Website/WatchIt.Website/Pages/SearchPage.razor +++ b/WatchIt.Website/WatchIt.Website/Pages/SearchPage.razor @@ -1,8 +1,7 @@ @using WatchIt.Common.Model.Movies +@using WatchIt.Common.Model.Persons @using WatchIt.Common.Model.Series -@using WatchIt.Common.Query -@using WatchIt.Website.Components.SearchPage -@using WatchIt.Website.Services.WebAPI.Movies +@using WatchIt.Website.Components.Pages.SearchPage.Panels @layout MainLayout @@ -12,68 +11,56 @@ -
- @if (_loaded) - { - if (string.IsNullOrWhiteSpace(_error)) - { -
-
-
-
-

- Search results for phrase: "@(DecodedQuery)" -

-
-
-
-
-
-
- -
-
-
-
- -
-
- } - else - { -
-
- -
-
- } - } - else - { -
-
- -
+
+
+
+

+ Search results for phrase: "@(DecodedQuery)" +

- } +
+ + +
\ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Pages/SearchPage.razor.cs b/WatchIt.Website/WatchIt.Website/Pages/SearchPage.razor.cs index 0e926d6..029a402 100644 --- a/WatchIt.Website/WatchIt.Website/Pages/SearchPage.razor.cs +++ b/WatchIt.Website/WatchIt.Website/Pages/SearchPage.razor.cs @@ -3,6 +3,7 @@ using Microsoft.AspNetCore.Components; using WatchIt.Website.Layout; using WatchIt.Website.Services.WebAPI.Media; using WatchIt.Website.Services.WebAPI.Movies; +using WatchIt.Website.Services.WebAPI.Persons; using WatchIt.Website.Services.WebAPI.Series; namespace WatchIt.Website.Pages; @@ -14,17 +15,9 @@ public partial class SearchPage : ComponentBase [Inject] private IMoviesWebAPIService MoviesWebAPIService { get; set; } = default!; [Inject] private ISeriesWebAPIService SeriesWebAPIService { get; set; } = default!; [Inject] private IMediaWebAPIService MediaWebAPIService { get; set; } = default!; + [Inject] private IPersonsWebAPIService PersonsWebAPIService { get; set; } = default!; #endregion - - - - #region FIELDS - - private bool _loaded; - private string? _error; - - #endregion @@ -43,19 +36,4 @@ public partial class SearchPage : ComponentBase public string DecodedQuery => WebUtility.UrlDecode(Query); #endregion - - - - #region PRIVATE METHODS - - protected override async Task OnAfterRenderAsync(bool firstRender) - { - if (firstRender) - { - _loaded = true; - StateHasChanged(); - } - } - - #endregion } \ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Program.cs b/WatchIt.Website/WatchIt.Website/Program.cs index 283995a..9f05d6f 100644 --- a/WatchIt.Website/WatchIt.Website/Program.cs +++ b/WatchIt.Website/WatchIt.Website/Program.cs @@ -9,9 +9,12 @@ using WatchIt.Website.Services.Utility.Authentication; using WatchIt.Website.Services.Utility.Configuration; using WatchIt.Website.Services.Utility.Tokens; using WatchIt.Website.Services.WebAPI.Accounts; +using WatchIt.Website.Services.WebAPI.Genders; using WatchIt.Website.Services.WebAPI.Media; using WatchIt.Website.Services.WebAPI.Movies; +using WatchIt.Website.Services.WebAPI.Persons; using WatchIt.Website.Services.WebAPI.Photos; +using WatchIt.Website.Services.WebAPI.Roles; using WatchIt.Website.Services.WebAPI.Series; namespace WatchIt.Website; @@ -71,10 +74,13 @@ public static class Program // WebAPI builder.Services.AddScoped(); + builder.Services.AddSingleton(); builder.Services.AddSingleton(); builder.Services.AddSingleton(); builder.Services.AddSingleton(); builder.Services.AddSingleton(); + builder.Services.AddSingleton(); + builder.Services.AddSingleton(); return builder; } diff --git a/WatchIt.Website/WatchIt.Website/WatchIt.Website.csproj b/WatchIt.Website/WatchIt.Website/WatchIt.Website.csproj index 3ba0027..9601cf7 100644 --- a/WatchIt.Website/WatchIt.Website/WatchIt.Website.csproj +++ b/WatchIt.Website/WatchIt.Website/WatchIt.Website.csproj @@ -20,9 +20,12 @@ + + + @@ -44,7 +47,13 @@ + + + + + + diff --git a/WatchIt.Website/WatchIt.Website/_Imports.razor b/WatchIt.Website/WatchIt.Website/_Imports.razor index 3a478f4..e95dbc3 100644 --- a/WatchIt.Website/WatchIt.Website/_Imports.razor +++ b/WatchIt.Website/WatchIt.Website/_Imports.razor @@ -8,7 +8,8 @@ @using Microsoft.JSInterop @using WatchIt.Website @using WatchIt.Website.Layout -@using WatchIt.Website.Components +@using WatchIt.Website.Components.Common.Subcomponents +@using WatchIt.Website.Components.Common.Panels @using WatchIt.Common.Model.Accounts @using WatchIt.Common.Model.Media @using WatchIt.Website.Services.Utility.Tokens diff --git a/WatchIt.Website/WatchIt.Website/appsettings.json b/WatchIt.Website/WatchIt.Website/appsettings.json index 02e7c38..2e65e00 100644 --- a/WatchIt.Website/WatchIt.Website/appsettings.json +++ b/WatchIt.Website/WatchIt.Website/appsettings.json @@ -10,6 +10,9 @@ "AccessToken": "access_token", "RefreshToken": "refresh_token" }, + "Style": { + "DefaultPanelPadding": 4 + }, "Endpoints": { "Base": "https://localhost:7160", "Accounts": { @@ -20,6 +23,13 @@ "Logout": "/logout", "GetProfilePicture": "/{0}/profile-picture" }, + "Genders": { + "Base": "/genders", + "GetAllGenders": "", + "GetGender": "/{0}", + "PostGender": "", + "DeleteGender": "/{0}" + }, "Genres": { "Base": "/genres", "GetAll": "", @@ -30,6 +40,7 @@ }, "Media": { "Base": "/media", + "GetAllMedia": "", "GetMedia": "/{0}", "GetMediaGenres": "/{0}/genres", "PostMediaGenre": "/{0}/genres/{1}", @@ -44,7 +55,11 @@ "DeleteMediaPoster": "/{0}/poster", "GetMediaPhotos": "/{0}/photos", "GetMediaPhotoRandomBackground": "/{0}/photos/random_background", - "PostMediaPhoto": "/{0}/photos" + "PostMediaPhoto": "/{0}/photos", + "GetMediaAllActorRoles": "/{0}/roles/actor", + "PostMediaActorRole": "/{0}/roles/actor", + "GetMediaAllCreatorRoles": "/{0}/roles/creator", + "PostMediaCreatorRole": "/{0}/roles/creator" }, "Movies": { "Base": "/movies", @@ -70,6 +85,50 @@ "DeletePhoto": "/{0}", "PutPhotoBackgroundData": "/{0}/background_data", "DeletePhotoBackgroundData": "/{0}/background_data" + }, + "Persons": { + "Base": "/persons", + "GetAllPersons": "", + "GetPerson": "/{0}", + "PostPerson": "", + "PutPerson": "/{0}", + "DeletePerson": "/{0}", + "GetPersonsViewRank": "/view", + "PostPersonsView": "/{0}/view", + "GetPersonPhoto": "/{0}/photo", + "PutPersonPhoto": "/{0}/photo", + "DeletePersonPhoto": "/{0}/photo", + "GetPersonAllActorRoles": "/{0}/roles/actor", + "PostPersonActorRole": "/{0}/roles/actor", + "GetPersonAllCreatorRoles": "/{0}/roles/creator", + "PostPersonCreatorRole": "/{0}/roles/creator", + "GetPersonGlobalRating": "/{0}/rating", + "GetPersonUserRating": "/{0}/rating/{1}" + }, + "Roles": { + "Base": "/roles", + "GetActorRole": "/actor/{0}", + "PutActorRole": "/actor/{0}", + "DeleteActorRole": "/actor/{0}", + "GetActorRoleRating": "/actor/{0}/rating", + "GetActorRoleRatingByUser": "/actor/{0}/rating/{1}", + "PutActorRoleRating": "/actor/{0}/rating", + "DeleteActorRoleRating": "/actor/{0}/rating", + "GetAllActorRoleTypes": "/actor/type", + "GetActorRoleType": "/actor/type/{0}", + "PostActorRoleType": "/actor/type", + "DeleteActorRoleType": "/actor/type/{0}", + "GetCreatorRole": "/creator/{0}", + "PutCreatorRole": "/creator/{0}", + "DeleteCreatorRole": "/creator/{0}", + "GetCreatorRoleRating": "/creator/{0}/rating", + "GetCreatorRoleRatingByUser": "/creator/{0}/rating/{1}", + "PutCreatorRoleRating": "/creator/{0}/rating", + "DeleteCreatorRoleRating": "/creator/{0}/rating", + "GetAllCreatorRoleTypes": "/creator/type", + "GetCreatorRoleType": "/creator/type/{0}", + "PostCreatorRoleType": "/creator/type", + "DeleteCreatorRoleType": "/creator/type/{0}" } } } diff --git a/WatchIt.Website/WatchIt.Website/wwwroot/assets/poster.png b/WatchIt.Website/WatchIt.Website/wwwroot/assets/media_poster.png similarity index 100% rename from WatchIt.Website/WatchIt.Website/wwwroot/assets/poster.png rename to WatchIt.Website/WatchIt.Website/wwwroot/assets/media_poster.png diff --git a/WatchIt.Website/WatchIt.Website/wwwroot/assets/person_poster.png b/WatchIt.Website/WatchIt.Website/wwwroot/assets/person_poster.png new file mode 100644 index 0000000..d305bd2 Binary files /dev/null and b/WatchIt.Website/WatchIt.Website/wwwroot/assets/person_poster.png differ diff --git a/WatchIt.Website/WatchIt.Website/wwwroot/css/gaps.css b/WatchIt.Website/WatchIt.Website/wwwroot/css/gaps.css new file mode 100644 index 0000000..3b45259 --- /dev/null +++ b/WatchIt.Website/WatchIt.Website/wwwroot/css/gaps.css @@ -0,0 +1,21 @@ +/* DEFAULT */ + +.mt-default { + margin-top: 1rem !important; +} + +.gx-default { + --bs-gutter-x: 1rem !important; +} + +.gap-default { + gap: 1rem; +} + + + +/* OTHERS */ + +.mt-over-panel-menu { + margin-top: 3rem !important; +} \ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/wwwroot/css/general.css b/WatchIt.Website/WatchIt.Website/wwwroot/css/general.css index 443ec27..319ee59 100644 --- a/WatchIt.Website/WatchIt.Website/wwwroot/css/general.css +++ b/WatchIt.Website/WatchIt.Website/wwwroot/css/general.css @@ -25,6 +25,8 @@ body, html { font-family: "PT Sans"; } + + /* CLASSES */ .container-grid { @@ -42,6 +44,28 @@ body, html { -webkit-text-fill-color: transparent; } +.table-transparent { + --bs-table-bg: transparent !important; +} + +.table td.table-cell-fit, .table th.table-cell-fit { + white-space: nowrap; + width: 1%; +} + +.metadata-pill { + border-color: gray; + border-width: 2px; + border-radius: 30px; + border-style: solid; + + padding: 2px 10px; +} + +.metadata-pill-container { + gap: 1rem; +} + @@ -62,21 +86,17 @@ body, html { margin-top: 9rem !important; } -.panel-header { - background-color: rgba(0, 0, 0, 0.8); -} .panel-regular { - background-color: rgba(0, 0, 0, 0.6); + background-color: rgba(0, 0, 0, 0.6) !important; } .panel-yellow { - background-color: rgba(255, 184, 58, 0.6); + background-color: rgba(255, 184, 58, 0.6) !important; } -.panel { - box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5); - backdrop-filter: blur(25px); +.pt-05 { + padding-top: 0.125rem !important; } diff --git a/WatchIt.Website/WatchIt.Website/wwwroot/css/panel.css b/WatchIt.Website/WatchIt.Website/wwwroot/css/panel.css new file mode 100644 index 0000000..0e200f3 --- /dev/null +++ b/WatchIt.Website/WatchIt.Website/wwwroot/css/panel.css @@ -0,0 +1,68 @@ +/* MAIN */ + +.panel { + box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5); + backdrop-filter: blur(25px); + + background-color: rgba(0, 0, 0, 0.6); + + border-radius: 0.5rem; + padding: 1.5rem; +} + + + +/* HEADER */ + +.panel-header { + padding: 0 1rem !important; + + background-color: rgba(0, 0, 0, 0.8); +} + + + +/* MENU */ + +.panel-menu { + gap: 1rem; + padding: 1rem 1.5rem !important; + + background-color: rgba(0, 0, 0, 0.8); +} + +.panel-menu > li > a { + --bs-nav-pills-link-active-bg: transparent; + --bs-nav-link-hover-color: white; + --bs-nav-link-color: #a6a6a6; + + --bs-nav-pills-border-radius: 1.25rem; + + padding: 0.25rem 0.5rem; + + border-style: solid; + border-width: 2px; + border-color: transparent; +} + +.panel-menu > li > a.active { + --bs-nav-link-color: white; + border-color: white; +} + + + +/* BACKGROUNDS */ + +.panel-background-gold { + background-color: rgba(255, 184, 58, 0.6); +} + + + +/* OTHERS */ + +.panel-text-title { + font-size: 1.5rem; + font-weight: bold; +} \ No newline at end of file diff --git a/WatchIt.sln b/WatchIt.sln index 07a0606..70d247e 100644 --- a/WatchIt.sln +++ b/WatchIt.sln @@ -88,6 +88,18 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WatchIt.WebAPI.Services.Con EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WatchIt.Website.Services.WebAPI.Photos", "WatchIt.Website\WatchIt.Website.Services\WatchIt.Website.Services.WebAPI\WatchIt.Website.Services.WebAPI.Photos\WatchIt.Website.Services.WebAPI.Photos.csproj", "{960A833F-C195-4D1D-AD4F-D00B57067181}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WatchIt.WebAPI.Services.Controllers.Persons", "WatchIt.WebAPI\WatchIt.WebAPI.Services\WatchIt.WebAPI.Services.Controllers\WatchIt.WebAPI.Services.Controllers.Persons\WatchIt.WebAPI.Services.Controllers.Persons.csproj", "{335686F5-65B8-4D66-AAA8-C5032906451D}" +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}" +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 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WatchIt.WebAPI.Services.Controllers.Roles", "WatchIt.WebAPI\WatchIt.WebAPI.Services\WatchIt.WebAPI.Services.Controllers\WatchIt.WebAPI.Services.Controllers.Roles\WatchIt.WebAPI.Services.Controllers.Roles.csproj", "{847D157A-E486-4FB6-9AA3-43931A60FB5F}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WatchIt.Website.Services.WebAPI.Roles", "WatchIt.Website\WatchIt.Website.Services\WatchIt.Website.Services.WebAPI\WatchIt.Website.Services.WebAPI.Roles\WatchIt.Website.Services.WebAPI.Roles.csproj", "{3D8B7909-BAC2-42FD-8A72-D1DADDB3BC82}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -134,6 +146,12 @@ Global {783C743A-85BF-4382-BFE5-7A90E3F3B8B6} = {46E3711F-18BD-4004-AF53-EA4D8643D92F} {ABDF8471-2FAB-4930-B016-7DD3E48AE6B8} = {CEC468DB-CC49-47D3-9E3E-1CC9530C3CE7} {960A833F-C195-4D1D-AD4F-D00B57067181} = {46E3711F-18BD-4004-AF53-EA4D8643D92F} + {335686F5-65B8-4D66-AAA8-C5032906451D} = {CEC468DB-CC49-47D3-9E3E-1CC9530C3CE7} + {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} + {847D157A-E486-4FB6-9AA3-43931A60FB5F} = {CEC468DB-CC49-47D3-9E3E-1CC9530C3CE7} + {3D8B7909-BAC2-42FD-8A72-D1DADDB3BC82} = {46E3711F-18BD-4004-AF53-EA4D8643D92F} EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {23383776-1F27-4B5D-8C7C-57BFF75FA473}.Debug|Any CPU.ActiveCfg = Debug|Any CPU @@ -264,5 +282,29 @@ Global {960A833F-C195-4D1D-AD4F-D00B57067181}.Debug|Any CPU.Build.0 = Debug|Any CPU {960A833F-C195-4D1D-AD4F-D00B57067181}.Release|Any CPU.ActiveCfg = Release|Any CPU {960A833F-C195-4D1D-AD4F-D00B57067181}.Release|Any CPU.Build.0 = Release|Any CPU + {335686F5-65B8-4D66-AAA8-C5032906451D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {335686F5-65B8-4D66-AAA8-C5032906451D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {335686F5-65B8-4D66-AAA8-C5032906451D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {335686F5-65B8-4D66-AAA8-C5032906451D}.Release|Any CPU.Build.0 = Release|Any CPU + {83D42D72-FF67-4577-8280-2ABD5B20F985}.Debug|Any CPU.ActiveCfg = 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.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 + {847D157A-E486-4FB6-9AA3-43931A60FB5F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {847D157A-E486-4FB6-9AA3-43931A60FB5F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {847D157A-E486-4FB6-9AA3-43931A60FB5F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {847D157A-E486-4FB6-9AA3-43931A60FB5F}.Release|Any CPU.Build.0 = Release|Any CPU + {3D8B7909-BAC2-42FD-8A72-D1DADDB3BC82}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3D8B7909-BAC2-42FD-8A72-D1DADDB3BC82}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3D8B7909-BAC2-42FD-8A72-D1DADDB3BC82}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3D8B7909-BAC2-42FD-8A72-D1DADDB3BC82}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection EndGlobal