2
.github/config/gitversion.yml
vendored
2
.github/config/gitversion.yml
vendored
@@ -1,4 +1,4 @@
|
||||
next-version: 0.2.0
|
||||
next-version: 0.3.0
|
||||
assembly-versioning-scheme: MajorMinorPatch
|
||||
assembly-file-versioning-scheme: MajorMinorPatch
|
||||
|
||||
|
||||
13
WatchIt.Common/WatchIt.Common.Model/Genders/Gender.cs
Normal file
13
WatchIt.Common/WatchIt.Common.Model/Genders/Gender.cs
Normal file
@@ -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
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using WatchIt.Common.Query;
|
||||
|
||||
namespace WatchIt.Common.Model.Genders;
|
||||
|
||||
public class GenderQueryParameters : QueryParameters<GenderResponse>
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
[FromQuery(Name = "name")]
|
||||
public string? Name { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PRIVATE METHODS
|
||||
|
||||
protected override bool IsMeetingConditions(GenderResponse item) => TestStringWithRegex(item.Name, Name);
|
||||
|
||||
#endregion
|
||||
}
|
||||
13
WatchIt.Common/WatchIt.Common.Model/Genders/GenderRequest.cs
Normal file
13
WatchIt.Common/WatchIt.Common.Model/Genders/GenderRequest.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
namespace WatchIt.Common.Model.Genders;
|
||||
|
||||
public class GenderRequest : Gender
|
||||
{
|
||||
#region PUBLIC METHODS
|
||||
|
||||
public Database.Model.Common.Gender CreateGender() => new Database.Model.Common.Gender()
|
||||
{
|
||||
Name = Name
|
||||
};
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -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<GenderResponse>
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
[JsonIgnore]
|
||||
public static IDictionary<string, Func<GenderResponse, IComparable>> OrderableProperties { get; } = new Dictionary<string, Func<GenderResponse, IComparable>>
|
||||
{
|
||||
{ "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
|
||||
}
|
||||
@@ -17,9 +17,9 @@ public class GenreQueryParameters : QueryParameters<GenreResponse>
|
||||
|
||||
|
||||
|
||||
#region PUBLIC METHODS
|
||||
#region PRIVATE METHODS
|
||||
|
||||
public override bool IsMeetingConditions(GenreResponse item) =>
|
||||
protected override bool IsMeetingConditions(GenreResponse item) =>
|
||||
(
|
||||
TestStringWithRegex(item.Name, Name)
|
||||
&&
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -59,9 +59,9 @@ public class MediaQueryParameters : QueryParameters<MediaResponse>
|
||||
|
||||
|
||||
|
||||
#region PUBLIC METHODS
|
||||
#region PRIVATE METHODS
|
||||
|
||||
public override bool IsMeetingConditions(MediaResponse item) =>
|
||||
protected override bool IsMeetingConditions(MediaResponse item) =>
|
||||
(
|
||||
Test(item.Type, Type)
|
||||
&&
|
||||
|
||||
@@ -51,7 +51,7 @@ public class MediaResponse : Media, IQueryOrderable<MediaResponse>
|
||||
ReleaseDate = media.ReleaseDate;
|
||||
Length = media.Length;
|
||||
Type = mediaType;
|
||||
Rating = new RatingResponse(media.RatingMedia);
|
||||
Rating = RatingResponse.Create(media.RatingMedia);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -65,9 +65,9 @@ public class MovieQueryParameters : QueryParameters<MovieResponse>
|
||||
|
||||
|
||||
|
||||
#region PUBLIC METHODS
|
||||
#region PRIVATE METHODS
|
||||
|
||||
public override bool IsMeetingConditions(MovieResponse item) =>
|
||||
protected override bool IsMeetingConditions(MovieResponse item) =>
|
||||
(
|
||||
TestStringWithRegex(item.Title, Title)
|
||||
&&
|
||||
|
||||
@@ -50,7 +50,7 @@ public class MovieResponse : Movie, IQueryOrderable<MovieResponse>
|
||||
ReleaseDate = mediaMovie.Media.ReleaseDate;
|
||||
Length = mediaMovie.Media.Length;
|
||||
Budget = mediaMovie.Budget;
|
||||
Rating = new RatingResponse(mediaMovie.Media.RatingMedia);
|
||||
Rating = RatingResponse.Create(mediaMovie.Media.RatingMedia);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
25
WatchIt.Common/WatchIt.Common.Model/Persons/Person.cs
Normal file
25
WatchIt.Common/WatchIt.Common.Model/Persons/Person.cs
Normal file
@@ -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
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace WatchIt.Common.Model.Persons;
|
||||
|
||||
public class PersonPhoto : Picture
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Text.Json.Serialization;
|
||||
using WatchIt.Database.Model.Person;
|
||||
|
||||
namespace WatchIt.Common.Model.Persons;
|
||||
|
||||
public class PersonPhotoRequest : PersonPhoto
|
||||
{
|
||||
#region CONSTRUCTORS
|
||||
|
||||
[JsonConstructor]
|
||||
public PersonPhotoRequest() {}
|
||||
|
||||
[SetsRequiredMembers]
|
||||
public PersonPhotoRequest(Picture image)
|
||||
{
|
||||
Image = image.Image;
|
||||
MimeType = image.MimeType;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PUBLIC METHODS
|
||||
|
||||
public PersonPhotoImage CreatePersonPhotoImage() => new PersonPhotoImage
|
||||
{
|
||||
Image = Image,
|
||||
MimeType = MimeType,
|
||||
};
|
||||
|
||||
public void UpdatePersonPhotoImage(PersonPhotoImage item)
|
||||
{
|
||||
item.Image = Image;
|
||||
item.MimeType = MimeType;
|
||||
item.UploadDate = DateTime.UtcNow;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Text.Json.Serialization;
|
||||
using WatchIt.Database.Model.Person;
|
||||
|
||||
namespace WatchIt.Common.Model.Persons;
|
||||
|
||||
public class PersonPhotoResponse : PersonPhoto
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
[JsonPropertyName("id")]
|
||||
public Guid Id { get; set; }
|
||||
|
||||
[JsonPropertyName("upload_date")]
|
||||
public DateTime UploadDate { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region CONSTRUCTORS
|
||||
|
||||
[JsonConstructor]
|
||||
public PersonPhotoResponse() {}
|
||||
|
||||
[SetsRequiredMembers]
|
||||
public PersonPhotoResponse(PersonPhotoImage personPhotoImage)
|
||||
{
|
||||
Id = personPhotoImage.Id;
|
||||
Image = personPhotoImage.Image;
|
||||
MimeType = personPhotoImage.MimeType;
|
||||
UploadDate = personPhotoImage.UploadDate;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using WatchIt.Common.Query;
|
||||
|
||||
namespace WatchIt.Common.Model.Persons;
|
||||
|
||||
public class PersonQueryParameters : QueryParameters<PersonResponse>
|
||||
{
|
||||
#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
|
||||
}
|
||||
63
WatchIt.Common/WatchIt.Common.Model/Persons/PersonRequest.cs
Normal file
63
WatchIt.Common/WatchIt.Common.Model/Persons/PersonRequest.cs
Normal file
@@ -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
|
||||
}
|
||||
@@ -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<PersonResponse>
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
[JsonIgnore]
|
||||
public static IDictionary<string, Func<PersonResponse, IComparable>> OrderableProperties { get; } = new Dictionary<string, Func<PersonResponse, IComparable>>
|
||||
{
|
||||
{ "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
|
||||
}
|
||||
@@ -32,9 +32,9 @@ public class PhotoQueryParameters : QueryParameters<PhotoResponse>
|
||||
|
||||
|
||||
|
||||
#region PUBLIC METHODS
|
||||
#region PRIVATE METHODS
|
||||
|
||||
public override bool IsMeetingConditions(PhotoResponse item) =>
|
||||
protected override bool IsMeetingConditions(PhotoResponse item) =>
|
||||
(
|
||||
TestStringWithRegex(item.MimeType, MimeType)
|
||||
&&
|
||||
|
||||
@@ -2,7 +2,7 @@ using System.Text.Json.Serialization;
|
||||
|
||||
namespace WatchIt.Common.Model;
|
||||
|
||||
public abstract class Picture
|
||||
public class Picture
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
|
||||
@@ -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> 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> ratingMedia) => Create(ratingMedia, x => x.Rating);
|
||||
|
||||
public static RatingResponse Create(IEnumerable<RatingPersonActorRole> ratingPersonActorRoles) => Create(ratingPersonActorRoles, x => x.Rating);
|
||||
|
||||
public static RatingResponse Create(IEnumerable<RatingPersonCreatorRole> ratingPersonCreatorRoles) => Create(ratingPersonCreatorRoles, x => x.Rating);
|
||||
|
||||
public static RatingResponse Create<T>(IEnumerable<T> ratingList, Func<T, short> ratingSelector) => new RatingResponse(ratingList.Sum(x => ratingSelector(x)), ratingList.Count());
|
||||
|
||||
public static RatingResponse Create(IEnumerable<PersonActorRole> personActorRoles, IEnumerable<PersonCreatorRole> personCreatorRoles)
|
||||
{
|
||||
IEnumerable<RatingPersonActorRole> ratingsActorRoles = personActorRoles.SelectMany(x => x.RatingPersonActorRole);
|
||||
IEnumerable<RatingPersonCreatorRole> ratingsCreatorRoles = personCreatorRoles.SelectMany(x => x.RatingPersonCreatorRole);
|
||||
return Create(ratingsActorRoles, ratingsCreatorRoles);
|
||||
}
|
||||
|
||||
public static RatingResponse Create(IEnumerable<RatingPersonActorRole> ratingsActorRoles, IEnumerable<RatingPersonCreatorRole> 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
|
||||
}
|
||||
16
WatchIt.Common/WatchIt.Common.Model/Roles/ActorRole.cs
Normal file
16
WatchIt.Common/WatchIt.Common.Model/Roles/ActorRole.cs
Normal file
@@ -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
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using System.Text.Json.Serialization;
|
||||
using WatchIt.Database.Model.Person;
|
||||
|
||||
namespace WatchIt.Common.Model.Roles;
|
||||
|
||||
public class ActorRoleMediaRequest : ActorRoleRequest, IActorRoleMediaRequest
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
[JsonPropertyName("person_id")]
|
||||
public long PersonId { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PUBLIC METHODS
|
||||
|
||||
public PersonActorRole CreateActorRole(long mediaId) => base.CreateActorRole(mediaId, PersonId);
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,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
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using WatchIt.Common.Query;
|
||||
|
||||
namespace WatchIt.Common.Model.Roles;
|
||||
|
||||
public abstract class ActorRoleQueryParameters : QueryParameters<ActorRoleResponse>
|
||||
{
|
||||
#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
|
||||
|
||||
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -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<ActorRoleResponse>, IRoleResponse
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
[JsonIgnore]
|
||||
public static IDictionary<string, Func<ActorRoleResponse, IComparable>> OrderableProperties { get; } = new Dictionary<string, Func<ActorRoleResponse, IComparable>>
|
||||
{
|
||||
{ "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
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
13
WatchIt.Common/WatchIt.Common.Model/Roles/CreatorRole.cs
Normal file
13
WatchIt.Common/WatchIt.Common.Model/Roles/CreatorRole.cs
Normal file
@@ -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
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using System.Text.Json.Serialization;
|
||||
using WatchIt.Database.Model.Person;
|
||||
|
||||
namespace WatchIt.Common.Model.Roles;
|
||||
|
||||
public class CreatorRoleMediaRequest : CreatorRoleRequest, ICreatorRoleMediaRequest
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
[JsonPropertyName("person_id")]
|
||||
public long PersonId { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PUBLIC METHODS
|
||||
|
||||
public PersonCreatorRole CreateCreatorRole(long mediaId) => base.CreateCreatorRole(mediaId, PersonId);
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,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
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using WatchIt.Common.Query;
|
||||
|
||||
namespace WatchIt.Common.Model.Roles;
|
||||
|
||||
public abstract class CreatorRoleQueryParameters : QueryParameters<CreatorRoleResponse>
|
||||
{
|
||||
#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
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -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<CreatorRoleResponse>, IRoleResponse
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
[JsonIgnore]
|
||||
public static IDictionary<string, Func<CreatorRoleResponse, IComparable>> OrderableProperties { get; } = new Dictionary<string, Func<CreatorRoleResponse, IComparable>>
|
||||
{
|
||||
{ "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
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace WatchIt.Common.Model.Roles;
|
||||
|
||||
public interface IActorRoleMediaRequest : IActorRoleRequest
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
public long PersonId { get; set; }
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace WatchIt.Common.Model.Roles;
|
||||
|
||||
public interface IActorRolePersonRequest : IActorRoleRequest
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
public long MediaId { get; set; }
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
namespace WatchIt.Common.Model.Roles;
|
||||
|
||||
public interface IActorRoleRequest
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
public short TypeId { get; set; }
|
||||
|
||||
public string Name { get; set; }
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace WatchIt.Common.Model.Roles;
|
||||
|
||||
public interface ICreatorRoleMediaRequest : ICreatorRoleRequest
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
public long PersonId { get; set; }
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace WatchIt.Common.Model.Roles;
|
||||
|
||||
public interface ICreatorRolePersonRequest : ICreatorRoleRequest
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
public long MediaId { get; set; }
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace WatchIt.Common.Model.Roles;
|
||||
|
||||
public interface ICreatorRoleRequest
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
public short TypeId { get; set; }
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -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; }
|
||||
}
|
||||
13
WatchIt.Common/WatchIt.Common.Model/Roles/RoleType.cs
Normal file
13
WatchIt.Common/WatchIt.Common.Model/Roles/RoleType.cs
Normal file
@@ -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
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using WatchIt.Common.Query;
|
||||
|
||||
namespace WatchIt.Common.Model.Roles;
|
||||
|
||||
public class RoleTypeQueryParameters : QueryParameters<RoleTypeResponse>
|
||||
{
|
||||
#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
|
||||
}
|
||||
18
WatchIt.Common/WatchIt.Common.Model/Roles/RoleTypeRequest.cs
Normal file
18
WatchIt.Common/WatchIt.Common.Model/Roles/RoleTypeRequest.cs
Normal file
@@ -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
|
||||
}
|
||||
@@ -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<RoleTypeResponse>
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
[JsonIgnore]
|
||||
public static IDictionary<string, Func<RoleTypeResponse, IComparable>> OrderableProperties { get; } = new Dictionary<string, Func<RoleTypeResponse, IComparable>>
|
||||
{
|
||||
{ "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
|
||||
}
|
||||
@@ -59,9 +59,9 @@ public class SeriesQueryParameters : QueryParameters<SeriesResponse>
|
||||
|
||||
|
||||
|
||||
#region PUBLIC METHODS
|
||||
#region PRIVATE METHODS
|
||||
|
||||
public override bool IsMeetingConditions(SeriesResponse item) =>
|
||||
protected override bool IsMeetingConditions(SeriesResponse item) =>
|
||||
(
|
||||
TestStringWithRegex(item.Title, Title)
|
||||
&&
|
||||
|
||||
@@ -50,7 +50,7 @@ public class SeriesResponse : Series, IQueryOrderable<SeriesResponse>
|
||||
ReleaseDate = mediaSeries.Media.ReleaseDate;
|
||||
Length = mediaSeries.Media.Length;
|
||||
HasEnded = mediaSeries.HasEnded;
|
||||
Rating = new RatingResponse(mediaSeries.Media.RatingMedia);
|
||||
Rating = RatingResponse.Create(mediaSeries.Media.RatingMedia);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -122,7 +122,7 @@ public abstract class QueryParameters<T> : QueryParameters where T : IQueryOrder
|
||||
{
|
||||
#region PUBLIC METHODS
|
||||
|
||||
public abstract bool IsMeetingConditions(T item);
|
||||
protected abstract bool IsMeetingConditions(T item);
|
||||
|
||||
public IEnumerable<T> PrepareData(IEnumerable<T> data)
|
||||
{
|
||||
|
||||
@@ -34,5 +34,9 @@ public class PersonActorRoleConfiguration : IEntityTypeConfiguration<PersonActor
|
||||
.IsRequired();
|
||||
builder.Property(x => x.PersonActorRoleTypeId)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.RoleName)
|
||||
.HasMaxLength(100)
|
||||
.IsRequired();
|
||||
}
|
||||
}
|
||||
@@ -66,7 +66,7 @@ public class DatabaseContext : DbContext
|
||||
// Rating
|
||||
public virtual DbSet<RatingMedia> RatingsMedia { get; set; }
|
||||
public virtual DbSet<RatingPersonActorRole> RatingsPersonActorRole { get; set; }
|
||||
public virtual DbSet<RatingPersonActorRole> RatingsPersonCreatorRole { get; set; }
|
||||
public virtual DbSet<RatingPersonCreatorRole> RatingsPersonCreatorRole { get; set; }
|
||||
public virtual DbSet<RatingMediaSeriesSeason> RatingsMediaSeriesSeason { get; set; }
|
||||
public virtual DbSet<RatingMediaSeriesEpisode> RatingsMediaSeriesEpisode { get; set; }
|
||||
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using WatchIt.Common.Model.Genders;
|
||||
using WatchIt.WebAPI.Services.Controllers.Genders;
|
||||
|
||||
namespace WatchIt.WebAPI.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("genders")]
|
||||
public class GendersController : ControllerBase
|
||||
{
|
||||
#region SERVICES
|
||||
|
||||
private readonly IGendersControllerService _gendersControllerService;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region CONSTRUCTORS
|
||||
|
||||
public GendersController(IGendersControllerService gendersControllerService)
|
||||
{
|
||||
_gendersControllerService = gendersControllerService;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region METHODS
|
||||
|
||||
#region Main
|
||||
|
||||
[HttpGet]
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(typeof(IEnumerable<GenderResponse>), StatusCodes.Status200OK)]
|
||||
public async Task<ActionResult> GetAllGenders(GenderQueryParameters query) => await _gendersControllerService.GetAllGenders(query);
|
||||
|
||||
[HttpGet("{id}")]
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(typeof(GenderResponse), StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||
public async Task<ActionResult> GetGender([FromRoute]short id) => await _gendersControllerService.GetGender(id);
|
||||
|
||||
[HttpPost]
|
||||
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
|
||||
[ProducesResponseType(typeof(GenderResponse), StatusCodes.Status201Created)]
|
||||
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(typeof(void), StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(typeof(void), StatusCodes.Status403Forbidden)]
|
||||
public async Task<ActionResult> PostGender([FromBody]GenderRequest body) => await _gendersControllerService.PostGender(body);
|
||||
|
||||
[HttpDelete("{id}")]
|
||||
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
|
||||
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||
[ProducesResponseType(typeof(void), StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(typeof(void), StatusCodes.Status403Forbidden)]
|
||||
public async Task<ActionResult> DeleteGender([FromRoute]short id) => await _gendersControllerService.DeleteGender(id);
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -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<MediaResponse>), StatusCodes.Status200OK)]
|
||||
public async Task<ActionResult> 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<ActionResult> PostPhoto([FromRoute]long id, [FromBody]MediaPhotoRequest body) => await _mediaControllerService.PostMediaPhoto(id, body);
|
||||
|
||||
#endregion
|
||||
|
||||
#region Roles
|
||||
|
||||
[HttpGet("{id}/roles/actor")]
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(typeof(IEnumerable<ActorRoleResponse>), StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||
public async Task<ActionResult> 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<ActionResult> PostMediaActorRole([FromRoute]long id, [FromBody]ActorRoleMediaRequest body) => await _mediaControllerService.PostMediaActorRole(id, body);
|
||||
|
||||
[HttpGet("{id}/roles/creator")]
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(typeof(IEnumerable<CreatorRoleResponse>), StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||
public async Task<ActionResult> 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<ActionResult> PostMediaCreatorRole([FromRoute]long id, [FromBody]CreatorRoleMediaRequest body) => await _mediaControllerService.PostMediaCreatorRole(id, body);
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
168
WatchIt.WebAPI/WatchIt.WebAPI.Controllers/PersonsController.cs
Normal file
168
WatchIt.WebAPI/WatchIt.WebAPI.Controllers/PersonsController.cs
Normal file
@@ -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<PersonResponse>), StatusCodes.Status200OK)]
|
||||
public async Task<ActionResult> GetAllMovies(PersonQueryParameters query) => await _personsControllerService.GetAllPersons(query);
|
||||
|
||||
[HttpGet("{id}")]
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(typeof(PersonResponse), StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||
public async Task<ActionResult> 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<ActionResult> 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<ActionResult> 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<ActionResult> DeleteMovie([FromRoute] long id) => await _personsControllerService.DeletePerson(id);
|
||||
|
||||
#endregion
|
||||
|
||||
#region View count
|
||||
|
||||
[HttpGet("view")]
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(typeof(IEnumerable<PersonResponse>), StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<ActionResult> 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<ActionResult> 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<ActionResult> GetPersonPhoto([FromRoute] long id) => await _personsControllerService.GetPersonPhoto(id);
|
||||
|
||||
[HttpPut("{id}/photo")]
|
||||
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
|
||||
[ProducesResponseType(typeof(PersonPhotoResponse), StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(typeof(void), StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(typeof(void), StatusCodes.Status403Forbidden)]
|
||||
public async Task<ActionResult> PutPersonPhoto([FromRoute]long id, [FromBody]PersonPhotoRequest body) => await _personsControllerService.PutPersonPhoto(id, body);
|
||||
|
||||
[HttpDelete("{id}/photo")]
|
||||
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
|
||||
[ProducesResponseType(typeof(void), StatusCodes.Status204NoContent)]
|
||||
[ProducesResponseType(typeof(void), StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(typeof(void), StatusCodes.Status403Forbidden)]
|
||||
public async Task<ActionResult> DeletePersonPhoto([FromRoute]long id) => await _personsControllerService.DeletePersonPhoto(id);
|
||||
|
||||
#endregion
|
||||
|
||||
#region Roles
|
||||
|
||||
[HttpGet("{id}/roles/actor")]
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(typeof(IEnumerable<ActorRoleResponse>), StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||
public async Task<ActionResult> 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<ActionResult> PostPersonActorRole([FromRoute]long id, [FromBody]ActorRolePersonRequest body) => await _personsControllerService.PostPersonActorRole(id, body);
|
||||
|
||||
[HttpGet("{id}/roles/creator")]
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(typeof(IEnumerable<CreatorRoleResponse>), StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||
public async Task<ActionResult> 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<ActionResult> 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<ActionResult> 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<ActionResult> GetPersonUserRating([FromRoute]long id, [FromRoute(Name = "user_id")]long userId) => await _personsControllerService.GetPersonUserRating(id, userId);
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
}
|
||||
192
WatchIt.WebAPI/WatchIt.WebAPI.Controllers/RolesController.cs
Normal file
192
WatchIt.WebAPI/WatchIt.WebAPI.Controllers/RolesController.cs
Normal file
@@ -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<ActorRoleResponse>), StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||
public async Task<ActionResult> 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<ActionResult> 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<ActionResult> DeleteActorRole([FromRoute]Guid id) => await _rolesControllerService.DeleteActorRole(id);
|
||||
|
||||
[HttpGet("actor/{id}/rating")]
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(typeof(RatingResponse), StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||
public async Task<ActionResult> 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<ActionResult> 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<ActionResult> 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<ActionResult> DeleteActorRoleRating([FromRoute] Guid id) => await _rolesControllerService.DeleteActorRoleRating(id);
|
||||
|
||||
[HttpGet("actor/type")]
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(typeof(IEnumerable<RoleTypeResponse>), StatusCodes.Status200OK)]
|
||||
public async Task<ActionResult> GetAllActorRoleTypes(RoleTypeQueryParameters query) => await _rolesControllerService.GetAllActorRoleTypes(query);
|
||||
|
||||
[HttpGet("actor/type/{type_id}")]
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(typeof(RoleTypeResponse), StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||
public async Task<ActionResult> 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<ActionResult> 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<ActionResult> DeleteActorRoleType([FromRoute(Name = "type_id")]short typeId) => await _rolesControllerService.DeleteActorRoleType(typeId);
|
||||
|
||||
#endregion
|
||||
|
||||
#region Creator
|
||||
|
||||
[HttpGet("creator/{id}")]
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(typeof(IEnumerable<CreatorRoleResponse>), StatusCodes.Status200OK)]
|
||||
public async Task<ActionResult> 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<ActionResult> 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<ActionResult> DeleteCreatorRole([FromRoute]Guid id) => await _rolesControllerService.DeleteCreatorRole(id);
|
||||
|
||||
[HttpGet("creator/{id}/rating")]
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(typeof(RatingResponse), StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||
public async Task<ActionResult> 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<ActionResult> 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<ActionResult> 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<ActionResult> DeleteCreatorRoleRating([FromRoute] Guid id) => await _rolesControllerService.DeleteCreatorRoleRating(id);
|
||||
|
||||
[HttpGet("creator/type")]
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(typeof(IEnumerable<RoleTypeResponse>), StatusCodes.Status200OK)]
|
||||
public async Task<ActionResult> GetAllCreatorRoleTypes(RoleTypeQueryParameters query) => await _rolesControllerService.GetAllCreatorRoleTypes(query);
|
||||
|
||||
[HttpGet("creator/type/{id}")]
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(typeof(RoleTypeResponse), StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||
public async Task<ActionResult> 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<ActionResult> 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<ActionResult> DeleteCreatorRoleType([FromRoute]short id) => await _rolesControllerService.DeleteCreatorRoleType(id);
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -14,10 +14,13 @@
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\WatchIt.Common\WatchIt.Common.Model\WatchIt.Common.Model.csproj" />
|
||||
<ProjectReference Include="..\WatchIt.WebAPI.Services\WatchIt.WebAPI.Services.Controllers\WatchIt.WebAPI.Services.Controllers.Accounts\WatchIt.WebAPI.Services.Controllers.Accounts.csproj" />
|
||||
<ProjectReference Include="..\WatchIt.WebAPI.Services\WatchIt.WebAPI.Services.Controllers\WatchIt.WebAPI.Services.Controllers.Genders\WatchIt.WebAPI.Services.Controllers.Genders.csproj" />
|
||||
<ProjectReference Include="..\WatchIt.WebAPI.Services\WatchIt.WebAPI.Services.Controllers\WatchIt.WebAPI.Services.Controllers.Genres\WatchIt.WebAPI.Services.Controllers.Genres.csproj" />
|
||||
<ProjectReference Include="..\WatchIt.WebAPI.Services\WatchIt.WebAPI.Services.Controllers\WatchIt.WebAPI.Services.Controllers.Media\WatchIt.WebAPI.Services.Controllers.Media.csproj" />
|
||||
<ProjectReference Include="..\WatchIt.WebAPI.Services\WatchIt.WebAPI.Services.Controllers\WatchIt.WebAPI.Services.Controllers.Movies\WatchIt.WebAPI.Services.Controllers.Movies.csproj" />
|
||||
<ProjectReference Include="..\WatchIt.WebAPI.Services\WatchIt.WebAPI.Services.Controllers\WatchIt.WebAPI.Services.Controllers.Persons\WatchIt.WebAPI.Services.Controllers.Persons.csproj" />
|
||||
<ProjectReference Include="..\WatchIt.WebAPI.Services\WatchIt.WebAPI.Services.Controllers\WatchIt.WebAPI.Services.Controllers.Photos\WatchIt.WebAPI.Services.Controllers.Photos.csproj" />
|
||||
<ProjectReference Include="..\WatchIt.WebAPI.Services\WatchIt.WebAPI.Services.Controllers\WatchIt.WebAPI.Services.Controllers.Roles\WatchIt.WebAPI.Services.Controllers.Roles.csproj" />
|
||||
<ProjectReference Include="..\WatchIt.WebAPI.Services\WatchIt.WebAPI.Services.Controllers\WatchIt.WebAPI.Services.Controllers.Series\WatchIt.WebAPI.Services.Controllers.Series.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -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<RequestResult> GetAllGenders(GenderQueryParameters query)
|
||||
{
|
||||
IEnumerable<Gender> rawData = await _database.Genders.ToListAsync();
|
||||
IEnumerable<GenderResponse> data = rawData.Select(x => new GenderResponse(x));
|
||||
data = query.PrepareData(data);
|
||||
return RequestResult.Ok(data);
|
||||
}
|
||||
|
||||
public async Task<RequestResult> GetGender(short id)
|
||||
{
|
||||
Gender? item = await _database.Genders.FirstOrDefaultAsync(x => x.Id == id);
|
||||
if (item is null)
|
||||
{
|
||||
return RequestResult.NotFound();
|
||||
}
|
||||
|
||||
GenderResponse data = new GenderResponse(item);
|
||||
return RequestResult.Ok(data);
|
||||
}
|
||||
|
||||
public async Task<RequestResult> PostGender(GenderRequest data)
|
||||
{
|
||||
UserValidator validator = _userService.GetValidator().MustBeAdmin();
|
||||
if (!validator.IsValid)
|
||||
{
|
||||
return RequestResult.Forbidden();
|
||||
}
|
||||
|
||||
Gender item = data.CreateGender();
|
||||
await _database.Genders.AddAsync(item);
|
||||
await _database.SaveChangesAsync();
|
||||
|
||||
return RequestResult.Created($"genres/{item.Id}", new GenderResponse(item));
|
||||
}
|
||||
|
||||
public async Task<RequestResult> DeleteGender(short id)
|
||||
{
|
||||
UserValidator validator = _userService.GetValidator().MustBeAdmin();
|
||||
if (!validator.IsValid)
|
||||
{
|
||||
return RequestResult.Forbidden();
|
||||
}
|
||||
|
||||
Gender? item = await _database.Genders.FirstOrDefaultAsync(x => x.Id == id);
|
||||
if (item is null)
|
||||
{
|
||||
return RequestResult.NoContent();
|
||||
}
|
||||
|
||||
_database.Genders.Attach(item);
|
||||
_database.Genders.Remove(item);
|
||||
await _database.SaveChangesAsync();
|
||||
|
||||
return RequestResult.NoContent();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using WatchIt.Common.Model.Genders;
|
||||
using WatchIt.WebAPI.Services.Controllers.Common;
|
||||
|
||||
namespace WatchIt.WebAPI.Services.Controllers.Genders;
|
||||
|
||||
public interface IGendersControllerService
|
||||
{
|
||||
Task<RequestResult> GetAllGenders(GenderQueryParameters query);
|
||||
Task<RequestResult> GetGender(short id);
|
||||
Task<RequestResult> PostGender(GenderRequest data);
|
||||
Task<RequestResult> DeleteGender(short id);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\..\WatchIt.Common\WatchIt.Common.Model\WatchIt.Common.Model.csproj" />
|
||||
<ProjectReference Include="..\..\..\..\WatchIt.Database\WatchIt.Database\WatchIt.Database.csproj" />
|
||||
<ProjectReference Include="..\..\WatchIt.WebAPI.Services.Utility\WatchIt.WebAPI.Services.Utility.User\WatchIt.WebAPI.Services.Utility.User.csproj" />
|
||||
<ProjectReference Include="..\WatchIt.WebAPI.Services.Controllers.Common\WatchIt.WebAPI.Services.Controllers.Common.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -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<RequestResult> GetAllMedia(MediaQueryParameters query);
|
||||
Task<RequestResult> GetMedia(long mediaId);
|
||||
|
||||
Task<RequestResult> GetMediaGenres(long mediaId);
|
||||
@@ -27,4 +29,9 @@ public interface IMediaControllerService
|
||||
Task<RequestResult> GetMediaPhotos(long mediaId, PhotoQueryParameters queryParameters);
|
||||
Task<RequestResult> GetMediaPhotoRandomBackground(long mediaId);
|
||||
Task<RequestResult> PostMediaPhoto(long mediaId, MediaPhotoRequest data);
|
||||
|
||||
Task<RequestResult> GetMediaAllActorRoles(long mediaId, ActorRoleMediaQueryParameters queryParameters);
|
||||
Task<RequestResult> PostMediaActorRole(long mediaId, ActorRoleMediaRequest data);
|
||||
Task<RequestResult> GetMediaAllCreatorRoles(long mediaId, CreatorRoleMediaQueryParameters queryParameters);
|
||||
Task<RequestResult> PostMediaCreatorRole(long mediaId, CreatorRoleMediaRequest data);
|
||||
}
|
||||
@@ -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<RequestResult> GetAllMedia(MediaQueryParameters query)
|
||||
{
|
||||
IEnumerable<Database.Model.Media.Media> rawData = await database.Media.ToListAsync();
|
||||
IEnumerable<MediaResponse> data = rawData.Select(x => new MediaResponse(x, database.MediaMovies.Any(y => y.Id == x.Id) ? MediaType.Movie : MediaType.Series));
|
||||
data = query.PrepareData(data);
|
||||
return RequestResult.Ok(data);
|
||||
}
|
||||
|
||||
public async Task<RequestResult> GetMedia(long mediaId)
|
||||
{
|
||||
Database.Model.Media.Media? item = await database.Media.FirstOrDefaultAsync(x => x.Id == mediaId);
|
||||
@@ -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<RequestResult> 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<RequestResult> 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<RequestResult> 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<PersonActorRole> dataRaw = await database.PersonActorRoles.Where(x => x.MediaId == mediaId).ToListAsync();
|
||||
IEnumerable<ActorRoleResponse> data = dataRaw.Select(x => new ActorRoleResponse(x));
|
||||
data = queryParameters.PrepareData(data);
|
||||
return RequestResult.Ok(data);
|
||||
}
|
||||
|
||||
public async Task<RequestResult> 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<RequestResult> 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<PersonCreatorRole> dataRaw = await database.PersonCreatorRoles.Where(x => x.MediaId == mediaId).ToListAsync();
|
||||
IEnumerable<CreatorRoleResponse> data = dataRaw.Select(x => new CreatorRoleResponse(x));
|
||||
data = queryParameters.PrepareData(data);
|
||||
return RequestResult.Ok(data);
|
||||
}
|
||||
|
||||
public async Task<RequestResult> 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
|
||||
}
|
||||
@@ -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<RequestResult> GetAllPersons(PersonQueryParameters query);
|
||||
Task<RequestResult> GetPerson(long id);
|
||||
Task<RequestResult> PostPerson(PersonRequest data);
|
||||
Task<RequestResult> PutPerson(long id, PersonRequest data);
|
||||
Task<RequestResult> DeletePerson(long id);
|
||||
|
||||
Task<RequestResult> GetPersonsViewRank(int first, int days);
|
||||
Task<RequestResult> PostPersonsView(long personId);
|
||||
|
||||
Task<RequestResult> GetPersonPhoto(long id);
|
||||
Task<RequestResult> PutPersonPhoto(long id, PersonPhotoRequest data);
|
||||
Task<RequestResult> DeletePersonPhoto(long id);
|
||||
|
||||
Task<RequestResult> GetPersonAllActorRoles(long personId, ActorRolePersonQueryParameters queryParameters);
|
||||
Task<RequestResult> PostPersonActorRole(long personId, ActorRolePersonRequest data);
|
||||
Task<RequestResult> GetPersonAllCreatorRoles(long personId, CreatorRolePersonQueryParameters queryParameters);
|
||||
Task<RequestResult> PostPersonCreatorRole(long personId, CreatorRolePersonRequest data);
|
||||
|
||||
Task<RequestResult> GetPersonGlobalRating(long id);
|
||||
Task<RequestResult> GetPersonUserRating(long id, long userId);
|
||||
}
|
||||
@@ -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<RequestResult> GetAllPersons(PersonQueryParameters query)
|
||||
{
|
||||
IEnumerable<Person> rawData = await _database.Persons.ToListAsync();
|
||||
IEnumerable<PersonResponse> data = rawData.Select(x => new PersonResponse(x));
|
||||
data = query.PrepareData(data);
|
||||
return RequestResult.Ok(data);
|
||||
}
|
||||
|
||||
public async Task<RequestResult> 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<RequestResult> 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<RequestResult> 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<RequestResult> 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<RequestResult> GetPersonsViewRank(int first, int days)
|
||||
{
|
||||
if (first < 1 || days < 1)
|
||||
{
|
||||
return RequestResult.BadRequest();
|
||||
}
|
||||
|
||||
DateOnly startDate = DateOnly.FromDateTime(DateTime.Now).AddDays(-days);
|
||||
IEnumerable<Person> 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<PersonResponse> data = rawData.Select(x => new PersonResponse(x));
|
||||
|
||||
return RequestResult.Ok(data);
|
||||
}
|
||||
|
||||
public async Task<RequestResult> 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<RequestResult> GetPersonPhoto(long id)
|
||||
{
|
||||
Person? person = await _database.Persons.FirstOrDefaultAsync(x => x.Id == id);
|
||||
if (person is null)
|
||||
{
|
||||
return RequestResult.BadRequest();
|
||||
}
|
||||
|
||||
PersonPhotoImage? photo = person.PersonPhoto;
|
||||
if (photo is null)
|
||||
{
|
||||
return RequestResult.NotFound();
|
||||
}
|
||||
|
||||
PersonPhotoResponse data = new PersonPhotoResponse(photo);
|
||||
return RequestResult.Ok(data);
|
||||
}
|
||||
|
||||
public async Task<RequestResult> PutPersonPhoto(long id, PersonPhotoRequest data)
|
||||
{
|
||||
UserValidator validator = _userService.GetValidator().MustBeAdmin();
|
||||
if (!validator.IsValid)
|
||||
{
|
||||
return RequestResult.Forbidden();
|
||||
}
|
||||
|
||||
Person? person = await _database.Persons.FirstOrDefaultAsync(x => x.Id == id);
|
||||
if (person is null)
|
||||
{
|
||||
return RequestResult.BadRequest();
|
||||
}
|
||||
|
||||
if (person.PersonPhoto is null)
|
||||
{
|
||||
PersonPhotoImage image = data.CreatePersonPhotoImage();
|
||||
await _database.PersonPhotoImages.AddAsync(image);
|
||||
await _database.SaveChangesAsync();
|
||||
|
||||
person.PersonPhotoId = image.Id;
|
||||
}
|
||||
else
|
||||
{
|
||||
data.UpdatePersonPhotoImage(person.PersonPhoto);
|
||||
}
|
||||
|
||||
await _database.SaveChangesAsync();
|
||||
|
||||
PersonPhotoResponse returnData = new PersonPhotoResponse(person.PersonPhoto);
|
||||
return RequestResult.Ok(returnData);
|
||||
}
|
||||
|
||||
public async Task<RequestResult> DeletePersonPhoto(long id)
|
||||
{
|
||||
UserValidator validator = _userService.GetValidator().MustBeAdmin();
|
||||
if (!validator.IsValid)
|
||||
{
|
||||
return RequestResult.Forbidden();
|
||||
}
|
||||
|
||||
Person? person = await _database.Persons.FirstOrDefaultAsync(x => x.Id == id);
|
||||
|
||||
if (person?.PersonPhoto != null)
|
||||
{
|
||||
_database.PersonPhotoImages.Attach(person.PersonPhoto);
|
||||
_database.PersonPhotoImages.Remove(person.PersonPhoto);
|
||||
await _database.SaveChangesAsync();
|
||||
}
|
||||
|
||||
return RequestResult.NoContent();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Roles
|
||||
|
||||
public async Task<RequestResult> 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<PersonActorRole> dataRaw = await _database.PersonActorRoles.Where(x => x.PersonId == personId).ToListAsync();
|
||||
IEnumerable<ActorRoleResponse> data = dataRaw.Select(x => new ActorRoleResponse(x));
|
||||
data = queryParameters.PrepareData(data);
|
||||
return RequestResult.Ok(data);
|
||||
}
|
||||
|
||||
public async Task<RequestResult> 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<RequestResult> GetPersonAllCreatorRoles(long personId, CreatorRolePersonQueryParameters queryParameters)
|
||||
{
|
||||
Person? media = await _database.Persons.FirstOrDefaultAsync(x => x.Id == personId);
|
||||
if (media is null)
|
||||
{
|
||||
return RequestResult.NotFound();
|
||||
}
|
||||
|
||||
IEnumerable<PersonCreatorRole> dataRaw = await _database.PersonCreatorRoles.Where(x => x.PersonId == personId).ToListAsync();
|
||||
IEnumerable<CreatorRoleResponse> data = dataRaw.Select(x => new CreatorRoleResponse(x));
|
||||
data = queryParameters.PrepareData(data);
|
||||
return RequestResult.Ok(data);
|
||||
}
|
||||
|
||||
public async Task<RequestResult> 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<RequestResult> 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<RequestResult> GetPersonUserRating(long id, long userId)
|
||||
{
|
||||
Person? item = await _database.Persons.FirstOrDefaultAsync(x => x.Id == id);
|
||||
if (item is null)
|
||||
{
|
||||
return RequestResult.NotFound();
|
||||
}
|
||||
|
||||
IEnumerable<RatingPersonActorRole> actorRoleRatings = item.PersonActorRoles.SelectMany(x => x.RatingPersonActorRole).Where(x => x.AccountId == userId);
|
||||
IEnumerable<RatingPersonCreatorRole> creatorRoleRatings = item.PersonCreatorRoles.SelectMany(x => x.RatingPersonCreatorRole).Where(x => x.AccountId == userId);
|
||||
RatingResponse ratingResponse = RatingResponse.Create(actorRoleRatings, creatorRoleRatings);
|
||||
|
||||
return RequestResult.Ok(ratingResponse);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\..\WatchIt.Common\WatchIt.Common.Model\WatchIt.Common.Model.csproj" />
|
||||
<ProjectReference Include="..\..\..\..\WatchIt.Database\WatchIt.Database\WatchIt.Database.csproj" />
|
||||
<ProjectReference Include="..\..\WatchIt.WebAPI.Services.Utility\WatchIt.WebAPI.Services.Utility.User\WatchIt.WebAPI.Services.Utility.User.csproj" />
|
||||
<ProjectReference Include="..\WatchIt.WebAPI.Services.Controllers.Common\WatchIt.WebAPI.Services.Controllers.Common.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -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<RequestResult> GetActorRole(Guid id);
|
||||
Task<RequestResult> PutActorRole(Guid id, ActorRoleUniversalRequest data);
|
||||
Task<RequestResult> DeleteActorRole(Guid id);
|
||||
Task<RequestResult> GetActorRoleRating(Guid id);
|
||||
Task<RequestResult> GetActorRoleRatingByUser(Guid id, long userId);
|
||||
Task<RequestResult> PutActorRoleRating(Guid id, RatingRequest data);
|
||||
Task<RequestResult> DeleteActorRoleRating(Guid id);
|
||||
Task<RequestResult> GetAllActorRoleTypes(RoleTypeQueryParameters query);
|
||||
Task<RequestResult> GetActorRoleType(short typeId);
|
||||
Task<RequestResult> PostActorRoleType(RoleTypeRequest data);
|
||||
Task<RequestResult> DeleteActorRoleType(short typeId);
|
||||
|
||||
Task<RequestResult> GetCreatorRole(Guid id);
|
||||
Task<RequestResult> PutCreatorRole(Guid id, CreatorRoleUniversalRequest data);
|
||||
Task<RequestResult> DeleteCreatorRole(Guid id);
|
||||
Task<RequestResult> GetCreatorRoleRating(Guid id);
|
||||
Task<RequestResult> GetCreatorRoleRatingByUser(Guid id, long userId);
|
||||
Task<RequestResult> PutCreatorRoleRating(Guid id, RatingRequest data);
|
||||
Task<RequestResult> DeleteCreatorRoleRating(Guid id);
|
||||
Task<RequestResult> GetAllCreatorRoleTypes(RoleTypeQueryParameters query);
|
||||
Task<RequestResult> GetCreatorRoleType(short typeId);
|
||||
Task<RequestResult> PostCreatorRoleType(RoleTypeRequest data);
|
||||
Task<RequestResult> DeleteCreatorRoleType(short typeId);
|
||||
}
|
||||
@@ -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<RequestResult> 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<RequestResult> 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<RequestResult> 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<RequestResult> 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<RequestResult> 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<RequestResult> 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<RequestResult> 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<RequestResult> GetAllActorRoleTypes(RoleTypeQueryParameters query)
|
||||
{
|
||||
IEnumerable<PersonActorRoleType> rawData = await _database.PersonActorRoleTypes.ToListAsync();
|
||||
IEnumerable<RoleTypeResponse> data = rawData.Select(x => new RoleTypeResponse(x));
|
||||
data = query.PrepareData(data);
|
||||
return RequestResult.Ok(data);
|
||||
}
|
||||
|
||||
public async Task<RequestResult> 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<RequestResult> 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<RequestResult> 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<RequestResult> 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<RequestResult> 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<RequestResult> 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<RequestResult> 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<RequestResult> 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<RequestResult> 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<RequestResult> 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<RequestResult> GetAllCreatorRoleTypes(RoleTypeQueryParameters query)
|
||||
{
|
||||
IEnumerable<PersonCreatorRoleType> rawData = await _database.PersonCreatorRoleTypes.ToListAsync();
|
||||
IEnumerable<RoleTypeResponse> data = rawData.Select(x => new RoleTypeResponse(x));
|
||||
data = query.PrepareData(data);
|
||||
return RequestResult.Ok(data);
|
||||
}
|
||||
|
||||
public async Task<RequestResult> 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<RequestResult> 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<RequestResult> 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
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\..\WatchIt.Common\WatchIt.Common.Model\WatchIt.Common.Model.csproj" />
|
||||
<ProjectReference Include="..\..\..\..\WatchIt.Database\WatchIt.Database\WatchIt.Database.csproj" />
|
||||
<ProjectReference Include="..\..\WatchIt.WebAPI.Services.Utility\WatchIt.WebAPI.Services.Utility.User\WatchIt.WebAPI.Services.Utility.User.csproj" />
|
||||
<ProjectReference Include="..\WatchIt.WebAPI.Services.Controllers.Common\WatchIt.WebAPI.Services.Controllers.Common.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,19 @@
|
||||
using FluentValidation;
|
||||
using WatchIt.Common.Model.Persons;
|
||||
using WatchIt.Database;
|
||||
|
||||
namespace WatchIt.WebAPI.Validators.Persons;
|
||||
|
||||
public class PersonRequestValidator : AbstractValidator<PersonRequest>
|
||||
{
|
||||
public PersonRequestValidator(DatabaseContext database)
|
||||
{
|
||||
RuleFor(x => x.Name).NotEmpty().MaximumLength(100);
|
||||
RuleFor(x => x.FullName).MaximumLength(200);
|
||||
RuleFor(x => x.Description).MaximumLength(1000);
|
||||
When(x => x.GenderId.HasValue, () =>
|
||||
{
|
||||
RuleFor(x => x.GenderId!.Value).MustBeIn(database.Genders.Select(g => g.Id));
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using FluentValidation;
|
||||
using WatchIt.Common.Model.Rating;
|
||||
|
||||
namespace WatchIt.WebAPI.Validators.Rating;
|
||||
|
||||
public class RatingRequestValidator : AbstractValidator<RatingRequest>
|
||||
{
|
||||
public RatingRequestValidator()
|
||||
{
|
||||
RuleFor(x => x.Rating).InclusiveBetween((short)1, (short)10);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using FluentValidation;
|
||||
using WatchIt.Common.Model.Roles;
|
||||
using WatchIt.Database;
|
||||
|
||||
namespace WatchIt.WebAPI.Validators.Roles;
|
||||
|
||||
public class ActorRoleMediaRequestValidator : AbstractValidator<ActorRoleMediaRequest>
|
||||
{
|
||||
public ActorRoleMediaRequestValidator(DatabaseContext database)
|
||||
{
|
||||
Include(new BaseActorRoleRequestValidator(database));
|
||||
RuleFor(x => x.PersonId).NotEmpty()
|
||||
.NotNull()
|
||||
.MustBeIn(database.Persons.Select(x => x.Id).ToList());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using FluentValidation;
|
||||
using WatchIt.Common.Model.Roles;
|
||||
using WatchIt.Database;
|
||||
|
||||
namespace WatchIt.WebAPI.Validators.Roles;
|
||||
|
||||
public class ActorRolePersonRequestValidator : AbstractValidator<ActorRolePersonRequest>
|
||||
{
|
||||
public ActorRolePersonRequestValidator(DatabaseContext database)
|
||||
{
|
||||
Include(new BaseActorRoleRequestValidator(database));
|
||||
RuleFor(x => x.MediaId).NotEmpty()
|
||||
.NotNull()
|
||||
.MustBeIn(database.Media.Select(x => x.Id).ToList());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using FluentValidation;
|
||||
using WatchIt.Common.Model.Roles;
|
||||
using WatchIt.Database;
|
||||
|
||||
namespace WatchIt.WebAPI.Validators.Roles;
|
||||
|
||||
public class ActorRoleUniversalRequestValidator : AbstractValidator<ActorRoleUniversalRequest>
|
||||
{
|
||||
public ActorRoleUniversalRequestValidator(DatabaseContext database)
|
||||
{
|
||||
Include(new BaseActorRoleRequestValidator(database));
|
||||
RuleFor(x => x.PersonId).NotEmpty()
|
||||
.NotNull()
|
||||
.MustBeIn(database.Persons.Select(x => x.Id).ToList());
|
||||
RuleFor(x => x.MediaId).NotEmpty()
|
||||
.NotNull()
|
||||
.MustBeIn(database.Media.Select(x => x.Id).ToList());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using FluentValidation;
|
||||
using WatchIt.Common.Model.Roles;
|
||||
using WatchIt.Database;
|
||||
|
||||
namespace WatchIt.WebAPI.Validators.Roles;
|
||||
|
||||
public class BaseActorRoleRequestValidator : AbstractValidator<ActorRoleRequest>
|
||||
{
|
||||
public BaseActorRoleRequestValidator(DatabaseContext database)
|
||||
{
|
||||
RuleFor(x => x.Name).NotEmpty()
|
||||
.MaximumLength(100);
|
||||
RuleFor(x => x.TypeId).NotEmpty()
|
||||
.NotNull()
|
||||
.MustBeIn(database.PersonActorRoleTypes.Select(x => x.Id).ToList());
|
||||
}
|
||||
}
|
||||
@@ -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<DatabaseContext>().Database.Migrate();
|
||||
DatabaseContext dbContext = scope.ServiceProvider.GetRequiredService<DatabaseContext>();
|
||||
|
||||
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<IAccountsControllerService, AccountsControllerService>();
|
||||
builder.Services.AddTransient<IGendersControllerService, GendersControllerService>();
|
||||
builder.Services.AddTransient<IGenresControllerService, GenresControllerService>();
|
||||
builder.Services.AddTransient<IMoviesControllerService, MoviesControllerService>();
|
||||
builder.Services.AddTransient<IMediaControllerService, MediaControllerService>();
|
||||
builder.Services.AddTransient<ISeriesControllerService, SeriesControllerService>();
|
||||
builder.Services.AddTransient<IPhotosControllerService, PhotosControllerService>();
|
||||
builder.Services.AddTransient<IPersonsControllerService, PersonsControllerService>();
|
||||
builder.Services.AddTransient<IRolesControllerService, RolesControllerService>();
|
||||
|
||||
return builder;
|
||||
}
|
||||
|
||||
@@ -27,6 +27,8 @@
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\WatchIt.Database\WatchIt.Database\WatchIt.Database.csproj" />
|
||||
<ProjectReference Include="..\WatchIt.WebAPI.Controllers\WatchIt.WebAPI.Controllers.csproj" />
|
||||
<ProjectReference Include="..\WatchIt.WebAPI.Services\WatchIt.WebAPI.Services.Controllers\WatchIt.WebAPI.Services.Controllers.Persons\WatchIt.WebAPI.Services.Controllers.Persons.csproj" />
|
||||
<ProjectReference Include="..\WatchIt.WebAPI.Services\WatchIt.WebAPI.Services.Controllers\WatchIt.WebAPI.Services.Controllers.Roles\WatchIt.WebAPI.Services.Controllers.Roles.csproj" />
|
||||
<ProjectReference Include="..\WatchIt.WebAPI.Services\WatchIt.WebAPI.Services.Utility\WatchIt.WebAPI.Services.Utility.Configuration\WatchIt.WebAPI.Services.Utility.Configuration.csproj" />
|
||||
<ProjectReference Include="..\WatchIt.WebAPI.Services\WatchIt.WebAPI.Services.Utility\WatchIt.WebAPI.Services.Utility.Tokens\WatchIt.WebAPI.Services.Utility.Tokens.csproj" />
|
||||
<ProjectReference Include="..\WatchIt.WebAPI.Validators\WatchIt.WebAPI.Validators.csproj" />
|
||||
|
||||
@@ -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; }
|
||||
}
|
||||
@@ -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; }
|
||||
}
|
||||
@@ -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; }
|
||||
}
|
||||
@@ -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; }
|
||||
}
|
||||
@@ -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; }
|
||||
}
|
||||
@@ -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; }
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace WatchIt.Website.Services.Utility.Configuration.Model;
|
||||
|
||||
public class Style
|
||||
{
|
||||
public int DefaultPanelPadding { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
using WatchIt.Common.Model.Genders;
|
||||
using WatchIt.Common.Services.HttpClient;
|
||||
using WatchIt.Website.Services.Utility.Configuration;
|
||||
using WatchIt.Website.Services.WebAPI.Common;
|
||||
|
||||
namespace WatchIt.Website.Services.WebAPI.Genders;
|
||||
|
||||
public class GendersWebAPIService : BaseWebAPIService, IGendersWebAPIService
|
||||
{
|
||||
#region SERVICES
|
||||
|
||||
private IHttpClientService _httpClientService;
|
||||
private IConfigurationService _configurationService;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region CONSTRUCTORS
|
||||
|
||||
public GendersWebAPIService(IHttpClientService httpClientService, IConfigurationService configurationService) : base(configurationService)
|
||||
{
|
||||
_httpClientService = httpClientService;
|
||||
_configurationService = configurationService;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PUBLIC METHODS
|
||||
|
||||
#region Main
|
||||
|
||||
public async Task GetAllGenders(GenderQueryParameters? query = null, Action<IEnumerable<GenderResponse>>? successAction = null)
|
||||
{
|
||||
string url = GetUrl(EndpointsConfiguration.Genders.GetAllGenders);
|
||||
|
||||
HttpRequest request = new HttpRequest(HttpMethodType.Get, url);
|
||||
request.Query = query;
|
||||
|
||||
HttpResponse response = await _httpClientService.SendRequestAsync(request);
|
||||
response.RegisterActionFor2XXSuccess(successAction)
|
||||
.ExecuteAction();
|
||||
}
|
||||
|
||||
public async Task GetGender(long id, Action<GenderResponse>? successAction = null, Action? notFoundAction = null)
|
||||
{
|
||||
string url = GetUrl(EndpointsConfiguration.Genders.GetGender, id);
|
||||
|
||||
HttpRequest request = new HttpRequest(HttpMethodType.Get, url);
|
||||
|
||||
HttpResponse response = await _httpClientService.SendRequestAsync(request);
|
||||
response.RegisterActionFor2XXSuccess(successAction)
|
||||
.RegisterActionFor404NotFound(notFoundAction)
|
||||
.ExecuteAction();
|
||||
}
|
||||
|
||||
public async Task PostGender(GenderRequest data, Action<GenderResponse>? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null)
|
||||
{
|
||||
string url = GetUrl(EndpointsConfiguration.Genders.PostGender);
|
||||
|
||||
HttpRequest request = new HttpRequest(HttpMethodType.Post, url);
|
||||
request.Body = data;
|
||||
|
||||
HttpResponse response = await _httpClientService.SendRequestAsync(request);
|
||||
response.RegisterActionFor2XXSuccess(successAction)
|
||||
.RegisterActionFor400BadRequest(badRequestAction)
|
||||
.RegisterActionFor401Unauthorized(unauthorizedAction)
|
||||
.RegisterActionFor403Forbidden(forbiddenAction)
|
||||
.ExecuteAction();
|
||||
}
|
||||
|
||||
public async Task DeleteGender(long id, Action? successAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null)
|
||||
{
|
||||
string url = GetUrl(EndpointsConfiguration.Genders.DeleteGender, id);
|
||||
|
||||
HttpRequest request = new HttpRequest(HttpMethodType.Delete, url);
|
||||
|
||||
HttpResponse response = await _httpClientService.SendRequestAsync(request);
|
||||
response.RegisterActionFor2XXSuccess(successAction)
|
||||
.RegisterActionFor401Unauthorized(unauthorizedAction)
|
||||
.RegisterActionFor403Forbidden(forbiddenAction)
|
||||
.ExecuteAction();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PRIVATE METHODS
|
||||
|
||||
protected override string GetServiceBase() => EndpointsConfiguration.Genders.Base;
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
using WatchIt.Common.Model.Genders;
|
||||
|
||||
namespace WatchIt.Website.Services.WebAPI.Genders;
|
||||
|
||||
public interface IGendersWebAPIService
|
||||
{
|
||||
Task GetAllGenders(GenderQueryParameters? query = null, Action<IEnumerable<GenderResponse>>? successAction = null);
|
||||
Task GetGender(long id, Action<GenderResponse>? successAction = null, Action? notFoundAction = null);
|
||||
Task PostGender(GenderRequest data, Action<GenderResponse>? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null);
|
||||
Task DeleteGender(long id, Action? successAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null);
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\..\WatchIt.Common\WatchIt.Common.Services\WatchIt.Common.Services.HttpClient\WatchIt.Common.Services.HttpClient.csproj" />
|
||||
<ProjectReference Include="..\WatchIt.Website.Services.WebAPI.Common\WatchIt.Website.Services.WebAPI.Common.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -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<IEnumerable<MediaResponse>>? successAction = null);
|
||||
Task GetMedia(long mediaId, Action<MediaResponse>? successAction = null, Action? notFoundAction = null);
|
||||
|
||||
Task GetMediaGenres(long mediaId, Action<IEnumerable<GenreResponse>>? successAction = null, Action? notFoundAction = null);
|
||||
@@ -27,4 +29,9 @@ public interface IMediaWebAPIService
|
||||
Task GetMediaPhotos(long mediaId, PhotoQueryParameters? query = null, Action<IEnumerable<PhotoResponse>>? successAction = null, Action? notFoundAction = null);
|
||||
Task GetMediaPhotoRandomBackground(long mediaId, Action<PhotoResponse>? successAction = null, Action? notFoundAction = null);
|
||||
Task PostMediaPhoto(long mediaId, MediaPhotoRequest data, Action? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null, Action? notFoundAction = null);
|
||||
|
||||
Task GetMediaAllActorRoles(long id, ActorRoleMediaQueryParameters? query = null, Action<IEnumerable<ActorRoleResponse>>? successAction = null);
|
||||
Task PostMediaActorRole(long id, ActorRoleMediaRequest data, Action<ActorRoleResponse>? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null);
|
||||
Task GetMediaAllCreatorRoles(long id, CreatorRoleMediaQueryParameters? query = null, Action<IEnumerable<CreatorRoleResponse>>? successAction = null);
|
||||
Task PostMediaCreatorRole(long id, CreatorRoleMediaRequest data, Action<CreatorRoleResponse>? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null);
|
||||
}
|
||||
@@ -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<IEnumerable<MediaResponse>>? successAction = null)
|
||||
{
|
||||
string url = GetUrl(EndpointsConfiguration.Media.GetAllMedia);
|
||||
|
||||
HttpRequest request = new HttpRequest(HttpMethodType.Get, url);
|
||||
request.Query = query;
|
||||
|
||||
HttpResponse response = await _httpClientService.SendRequestAsync(request);
|
||||
response.RegisterActionFor2XXSuccess(successAction)
|
||||
.ExecuteAction();
|
||||
}
|
||||
|
||||
public async Task GetMedia(long mediaId, Action<MediaResponse>? successAction = null, Action? notFoundAction = null)
|
||||
{
|
||||
string url = GetUrl(EndpointsConfiguration.Media.GetMedia, mediaId);
|
||||
@@ -258,6 +271,64 @@ public class MediaWebAPIService : BaseWebAPIService, IMediaWebAPIService
|
||||
|
||||
#endregion
|
||||
|
||||
#region Roles
|
||||
|
||||
public async Task GetMediaAllActorRoles(long id, ActorRoleMediaQueryParameters? query = null, Action<IEnumerable<ActorRoleResponse>>? 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<ActorRoleResponse>? successAction = null, Action<IDictionary<string, string[]>>? 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<IEnumerable<CreatorRoleResponse>>? 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<CreatorRoleResponse>? successAction = null, Action<IDictionary<string, string[]>>? 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
|
||||
|
||||
|
||||
|
||||
@@ -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<IEnumerable<PersonResponse>>? successAction = null);
|
||||
Task GetPerson(long id, Action<PersonResponse>? successAction = null, Action? notFoundAction = null);
|
||||
Task PostPerson(PersonRequest data, Action<PersonResponse>? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null);
|
||||
Task PutPerson(long id, PersonRequest data, Action? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null);
|
||||
Task DeletePerson(long id, Action? successAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null);
|
||||
|
||||
Task GetPersonsViewRank(int? first = null, int? days = null, Action<IEnumerable<PersonResponse>>? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null);
|
||||
Task PostPersonView(long personId, Action? successAction = null, Action? notFoundAction = null);
|
||||
|
||||
Task GetPersonPhoto(long id, Action<PersonPhotoResponse>? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? notFoundAction = null);
|
||||
Task PutPersonPhoto(long id, PersonPhotoRequest data, Action<PersonPhotoResponse>? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null);
|
||||
Task DeletePersonPhoto(long id, Action? successAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null);
|
||||
|
||||
Task GetPersonAllActorRoles(long id, ActorRolePersonQueryParameters? query = null, Action<IEnumerable<ActorRoleResponse>>? successAction = null);
|
||||
Task PostPersonActorRole(long id, ActorRolePersonRequest data, Action<ActorRoleResponse>? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null);
|
||||
Task GetPersonAllCreatorRoles(long id, CreatorRolePersonQueryParameters? query = null, Action<IEnumerable<CreatorRoleResponse>>? successAction = null);
|
||||
Task PostPersonCreatorRole(long id, CreatorRolePersonRequest data, Action<CreatorRoleResponse>? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null);
|
||||
|
||||
Task GetPersonGlobalRating(long id, Action<RatingResponse>? successAction = null, Action? notFoundAction = null);
|
||||
Task GetPersonUserRating(long id, long userId, Action<RatingResponse>? successAction = null, Action? notFoundAction = null);
|
||||
}
|
||||
@@ -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<IEnumerable<PersonResponse>>? 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<PersonResponse>? 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<PersonResponse>? successAction = null, Action<IDictionary<string, string[]>>? 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<IDictionary<string, string[]>>? 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<IEnumerable<PersonResponse>>? successAction = null, Action<IDictionary<string, string[]>>? 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<PersonPhotoResponse>? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? notFoundAction = null)
|
||||
{
|
||||
string url = GetUrl(EndpointsConfiguration.Persons.GetPersonPhoto, id);
|
||||
|
||||
HttpRequest request = new HttpRequest(HttpMethodType.Get, url);
|
||||
|
||||
HttpResponse response = await _httpClientService.SendRequestAsync(request);
|
||||
response.RegisterActionFor2XXSuccess(successAction)
|
||||
.RegisterActionFor400BadRequest(badRequestAction)
|
||||
.RegisterActionFor404NotFound(notFoundAction)
|
||||
.ExecuteAction();
|
||||
}
|
||||
|
||||
public async Task PutPersonPhoto(long id, PersonPhotoRequest data, Action<PersonPhotoResponse>? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null)
|
||||
{
|
||||
string url = GetUrl(EndpointsConfiguration.Persons.PutPersonPhoto, id);
|
||||
|
||||
HttpRequest request = new HttpRequest(HttpMethodType.Put, url)
|
||||
{
|
||||
Body = data
|
||||
};
|
||||
|
||||
HttpResponse response = await _httpClientService.SendRequestAsync(request);
|
||||
response.RegisterActionFor2XXSuccess(successAction)
|
||||
.RegisterActionFor400BadRequest(badRequestAction)
|
||||
.RegisterActionFor401Unauthorized(unauthorizedAction)
|
||||
.RegisterActionFor403Forbidden(forbiddenAction)
|
||||
.ExecuteAction();
|
||||
}
|
||||
|
||||
public async Task DeletePersonPhoto(long id, Action? successAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null)
|
||||
{
|
||||
string url = GetUrl(EndpointsConfiguration.Persons.DeletePersonPhoto, id);
|
||||
|
||||
HttpRequest request = new HttpRequest(HttpMethodType.Delete, url);
|
||||
|
||||
HttpResponse response = await _httpClientService.SendRequestAsync(request);
|
||||
response.RegisterActionFor2XXSuccess(successAction)
|
||||
.RegisterActionFor401Unauthorized(unauthorizedAction)
|
||||
.RegisterActionFor403Forbidden(forbiddenAction)
|
||||
.ExecuteAction();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Roles
|
||||
|
||||
public async Task GetPersonAllActorRoles(long id, ActorRolePersonQueryParameters? query = null, Action<IEnumerable<ActorRoleResponse>>? 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<ActorRoleResponse>? successAction = null, Action<IDictionary<string, string[]>>? 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<IEnumerable<CreatorRoleResponse>>? 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<CreatorRoleResponse>? successAction = null, Action<IDictionary<string, string[]>>? 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<RatingResponse>? 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<RatingResponse>? 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
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\..\WatchIt.Common\WatchIt.Common.Services\WatchIt.Common.Services.HttpClient\WatchIt.Common.Services.HttpClient.csproj" />
|
||||
<ProjectReference Include="..\WatchIt.Website.Services.WebAPI.Common\WatchIt.Website.Services.WebAPI.Common.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -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<ActorRoleResponse>? successAction = null, Action? notFoundAction = null);
|
||||
Task PutActorRole(Guid id, ActorRoleUniversalRequest data, Action? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null, Action? notFoundAction = null);
|
||||
Task DeleteActorRole(Guid id, Action? successAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null);
|
||||
Task GetActorRoleRating(Guid id, Action<RatingResponse>? successAction = null, Action? notFoundAction = null);
|
||||
Task GetActorRoleRatingByUser(Guid id, long userId, Action<short>? successAction = null, Action? notFoundAction = null);
|
||||
Task PutActorRoleRating(Guid id, RatingRequest body, Action? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? notFoundAction = null);
|
||||
Task DeleteActorRoleRating(Guid id, Action? successAction = null, Action? unauthorizedAction = null);
|
||||
Task GetAllActorRoleTypes(RoleTypeQueryParameters? query = null, Action<IEnumerable<RoleTypeResponse>>? successAction = null);
|
||||
Task GetActorRoleType(long typeId, Action<RoleTypeResponse>? successAction = null, Action? notFoundAction = null);
|
||||
Task PostActorRoleType(RoleTypeRequest data, Action<RoleTypeResponse>? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null);
|
||||
Task DeleteActorRoleType(long typeId, Action? successAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null);
|
||||
|
||||
Task GetCreatorRole(Guid id, Action<CreatorRoleResponse>? successAction = null, Action? notFoundAction = null);
|
||||
Task PutCreatorRole(Guid id, CreatorRoleUniversalRequest data, Action? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null, Action? notFoundAction = null);
|
||||
Task DeleteCreatorRole(Guid id, Action? successAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null);
|
||||
Task GetCreatorRoleRating(Guid id, Action<RatingResponse>? successAction = null, Action? notFoundAction = null);
|
||||
Task GetCreatorRoleRatingByUser(Guid id, long userId, Action<short>? successAction = null, Action? notFoundAction = null);
|
||||
Task PutCreatorRoleRating(Guid id, RatingRequest body, Action? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? notFoundAction = null);
|
||||
Task DeleteCreatorRoleRating(Guid id, Action? successAction = null, Action? unauthorizedAction = null);
|
||||
Task GetAllCreatorRoleTypes(RoleTypeQueryParameters? query = null, Action<IEnumerable<RoleTypeResponse>>? successAction = null);
|
||||
Task GetCreatorRoleType(long typeId, Action<RoleTypeResponse>? successAction = null, Action? notFoundAction = null);
|
||||
Task PostCreatorRoleType(RoleTypeRequest data, Action<RoleTypeResponse>? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null);
|
||||
Task DeleteCreatorRoleType(long typeId, Action? successAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null);
|
||||
}
|
||||
@@ -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<ActorRoleResponse>? 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<IDictionary<string, string[]>>? 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<RatingResponse>? 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<short>? 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<IDictionary<string, string[]>>? 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<IEnumerable<RoleTypeResponse>>? 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<RoleTypeResponse>? 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<RoleTypeResponse>? successAction = null, Action<IDictionary<string, string[]>>? 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<CreatorRoleResponse>? 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<IDictionary<string, string[]>>? 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<RatingResponse>? 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<short>? 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<IDictionary<string, string[]>>? 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<IEnumerable<RoleTypeResponse>>? 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<RoleTypeResponse>? 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<RoleTypeResponse>? successAction = null, Action<IDictionary<string, string[]>>? 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
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\..\WatchIt.Common\WatchIt.Common.Services\WatchIt.Common.Services.HttpClient\WatchIt.Common.Services.HttpClient.csproj" />
|
||||
<ProjectReference Include="..\WatchIt.Website.Services.WebAPI.Common\WatchIt.Website.Services.WebAPI.Common.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -9,9 +9,11 @@
|
||||
<link rel="icon" type="image/png" href="favicon.png"/>
|
||||
|
||||
<!-- CSS -->
|
||||
<link rel="stylesheet" href="css/general.css?version=0.2.0.3"/>
|
||||
<link rel="stylesheet" href="css/main_button.css?version=0.2.0.0"/>
|
||||
<link rel="stylesheet" href="WatchIt.Website.styles.css?version=0.2.0.12"/>
|
||||
<link rel="stylesheet" href="css/general.css?version=0.3.0.5"/>
|
||||
<link rel="stylesheet" href="css/panel.css?version=0.3.0.3"/>
|
||||
<link rel="stylesheet" href="css/main_button.css?version=0.3.0.0"/>
|
||||
<link rel="stylesheet" href="css/gaps.css?version=0.3.0.1"/>
|
||||
<link rel="stylesheet" href="WatchIt.Website.styles.css?version=0.3.0.22"/>
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
|
||||
|
||||
<!-- BOOTSTRAP -->
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
<div class="panel">
|
||||
<div class="vstack">
|
||||
<div class="d-flex justify-content-center">
|
||||
<div class="text-danger icon-size">⚠︎</div>
|
||||
</div>
|
||||
<div class="d-flex justify-content-center">
|
||||
<h3 class="text-danger">An error occured while loading a page</h3>
|
||||
</div>
|
||||
@if (!string.IsNullOrWhiteSpace(ErrorMessage))
|
||||
{
|
||||
<div class="d-flex justify-content-center">
|
||||
<p>@ErrorMessage</p>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
@@ -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
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user