Merge pull request #123 from mateuszskoczek/features/roles_rating_endpoints
roles rating endpoints added
This commit is contained in:
@@ -33,7 +33,13 @@ public class RatingResponse
|
||||
|
||||
public static RatingResponse Create(long ratingSum, long ratingCount) => new RatingResponse(ratingSum, ratingCount);
|
||||
|
||||
public static RatingResponse Create(IEnumerable<RatingMedia> ratingMedia) => new RatingResponse(ratingMedia.Sum(x => x.Rating), ratingMedia.Count());
|
||||
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)
|
||||
{
|
||||
|
||||
@@ -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; }
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ 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;
|
||||
|
||||
@@ -56,6 +57,32 @@ public class RolesController : ControllerBase
|
||||
[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)]
|
||||
@@ -107,6 +134,32 @@ public class RolesController : ControllerBase
|
||||
[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)]
|
||||
|
||||
@@ -125,29 +125,17 @@ public class MediaControllerService(DatabaseContext database, IUserService userS
|
||||
|
||||
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)
|
||||
{
|
||||
@@ -159,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
|
||||
{
|
||||
@@ -167,7 +155,7 @@ public class MediaControllerService(DatabaseContext database, IUserService userS
|
||||
{
|
||||
AccountId = userId,
|
||||
MediaId = mediaId,
|
||||
Rating = ratingValue
|
||||
Rating = data.Rating
|
||||
};
|
||||
await database.RatingsMedia.AddAsync(rating);
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using WatchIt.Common.Model.Rating;
|
||||
using WatchIt.Common.Model.Roles;
|
||||
using WatchIt.WebAPI.Services.Controllers.Common;
|
||||
|
||||
@@ -8,6 +9,10 @@ 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);
|
||||
@@ -16,6 +21,10 @@ public interface IRolesControllerService
|
||||
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);
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
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;
|
||||
|
||||
@@ -87,6 +89,77 @@ public class RolesControllerService : IRolesControllerService
|
||||
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();
|
||||
@@ -200,6 +273,77 @@ public class RolesControllerService : IRolesControllerService
|
||||
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();
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,10 @@ public class Roles
|
||||
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; }
|
||||
@@ -13,6 +17,10 @@ public class Roles
|
||||
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; }
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using WatchIt.Common.Model.Rating;
|
||||
using WatchIt.Common.Model.Roles;
|
||||
|
||||
namespace WatchIt.Website.Services.WebAPI.Roles;
|
||||
@@ -7,6 +8,10 @@ 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);
|
||||
@@ -15,6 +20,10 @@ public interface IRolesWebAPIService
|
||||
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);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using WatchIt.Common.Model.Roles;
|
||||
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;
|
||||
@@ -71,6 +72,59 @@ public class RolesWebAPIService : BaseWebAPIService, IRolesWebAPIService
|
||||
.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);
|
||||
@@ -168,6 +222,59 @@ public class RolesWebAPIService : BaseWebAPIService, IRolesWebAPIService
|
||||
.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);
|
||||
|
||||
@@ -108,6 +108,10 @@
|
||||
"GetActorRole": "/actor/{0}",
|
||||
"PutActorRole": "/actor/{0}",
|
||||
"DeleteActorRole": "/actor/{0}",
|
||||
"GetActorRoleRating": "/actor/{0}/rating",
|
||||
"GetActorRoleRatingByUser": "/actor/{0}/rating/{1}",
|
||||
"PutActorRoleRating": "/actor/{0}/rating",
|
||||
"DeleteActorRoleRating": "/actor/{0}/rating",
|
||||
"GetAllActorRoleTypes": "/actor/type",
|
||||
"GetActorRoleType": "/actor/type/{0}",
|
||||
"PostActorRoleType": "/actor/type",
|
||||
@@ -115,6 +119,10 @@
|
||||
"GetCreatorRole": "/creator/{0}",
|
||||
"PutCreatorRole": "/creator/{0}",
|
||||
"DeleteCreatorRole": "/creator/{0}",
|
||||
"GetCreatorRoleRating": "/creator/{0}/rating",
|
||||
"GetCreatorRoleRatingByUser": "/creator/{0}/rating/{1}",
|
||||
"PutCreatorRoleRating": "/creator/{0}/rating",
|
||||
"DeleteCreatorRoleRating": "/creator/{0}/rating",
|
||||
"GetAllCreatorRoleTypes": "/creator/type",
|
||||
"GetCreatorRoleType": "/creator/type/{0}",
|
||||
"PostCreatorRoleType": "/creator/type",
|
||||
|
||||
Reference in New Issue
Block a user