view rank get endpoint client service method for movies added
This commit is contained in:
@@ -5,6 +5,7 @@ public class Endpoints
|
||||
public string Base { get; set; }
|
||||
public Accounts Accounts { get; set; }
|
||||
public Genres Genres { get; set; }
|
||||
public Movies Movies { get; set; }
|
||||
public Media Media { get; set; }
|
||||
public Movies Movies { get; set; }
|
||||
public Series Series { get; set; }
|
||||
}
|
||||
@@ -3,9 +3,10 @@
|
||||
public class Movies
|
||||
{
|
||||
public string Base { get; set; }
|
||||
public string GetAll { get; set; }
|
||||
public string Get { get; set; }
|
||||
public string Post { get; set; }
|
||||
public string Put { get; set; }
|
||||
public string Delete { get; set; }
|
||||
public string GetAllMovies { get; set; }
|
||||
public string GetMovie { get; set; }
|
||||
public string PostMovie { get; set; }
|
||||
public string PutMovie { get; set; }
|
||||
public string DeleteMovie { get; set; }
|
||||
public string GetMoviesViewRank { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
namespace WatchIt.Website.Services.Utility.Configuration.Model;
|
||||
|
||||
public class Series
|
||||
{
|
||||
public string Base { get; set; }
|
||||
public string GetAllSeries { get; set; }
|
||||
public string GetSeries { get; set; }
|
||||
public string PostSeries { get; set; }
|
||||
public string PutSeries { get; set; }
|
||||
public string DeleteSeries { get; set; }
|
||||
public string GetSeriesViewRank { get; set; }
|
||||
}
|
||||
@@ -4,9 +4,9 @@ namespace WatchIt.Website.Services.WebAPI.Movies;
|
||||
|
||||
public interface IMoviesWebAPIService
|
||||
{
|
||||
Task GetAll(MovieQueryParameters? query = null, Action<IEnumerable<MovieResponse>>? successAction = null);
|
||||
Task Post(MovieRequest data, Action<MovieResponse>? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null);
|
||||
Task Get(long id, Action<MovieResponse>? successAction = null, Action? notFoundAction = null);
|
||||
Task Put(long id, MovieRequest data, Action? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null);
|
||||
Task Delete(long id, Action? successAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null);
|
||||
Task GetAllMovies(MovieQueryParameters? query = null, Action<IEnumerable<MovieResponse>>? successAction = null);
|
||||
Task PostMovie(MovieRequest data, Action<MovieResponse>? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null);
|
||||
Task GetMovie(long id, Action<MovieResponse>? successAction = null, Action? notFoundAction = null);
|
||||
Task PutMovie(long id, MovieRequest data, Action? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null);
|
||||
Task DeleteMovie(long id, Action? successAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null);
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using System.Text;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.Extensions.Primitives;
|
||||
using WatchIt.Common.Model.Movies;
|
||||
using WatchIt.Common.Services.HttpClient;
|
||||
using WatchIt.Website.Services.Utility.Configuration;
|
||||
@@ -28,11 +30,14 @@ public class MoviesWebAPIService : BaseWebAPIService, IMoviesWebAPIService
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PUBLIC METHODS
|
||||
|
||||
#region Main
|
||||
|
||||
public async Task GetAll(MovieQueryParameters? query = null, Action<IEnumerable<MovieResponse>>? successAction = null)
|
||||
public async Task GetAllMovies(MovieQueryParameters? query = null, Action<IEnumerable<MovieResponse>>? successAction = null)
|
||||
{
|
||||
string url = GetUrl(EndpointsConfiguration.Movies.GetAll);
|
||||
string url = GetUrl(EndpointsConfiguration.Movies.GetAllMovies);
|
||||
|
||||
HttpRequest request = new HttpRequest(HttpMethodType.Get, url);
|
||||
request.Query = query;
|
||||
@@ -42,9 +47,21 @@ public class MoviesWebAPIService : BaseWebAPIService, IMoviesWebAPIService
|
||||
.ExecuteAction();
|
||||
}
|
||||
|
||||
public async Task Post(MovieRequest data, Action<MovieResponse>? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null)
|
||||
public async Task GetMovie(long id, Action<MovieResponse>? successAction = null, Action? notFoundAction = null)
|
||||
{
|
||||
string url = GetUrl(EndpointsConfiguration.Movies.Post);
|
||||
string url = GetUrl(EndpointsConfiguration.Movies.GetMovie, id);
|
||||
|
||||
HttpRequest request = new HttpRequest(HttpMethodType.Get, url);
|
||||
|
||||
HttpResponse response = await _httpClientService.SendRequestAsync(request);
|
||||
response.RegisterActionFor2XXSuccess(successAction)
|
||||
.RegisterActionFor404NotFound(notFoundAction)
|
||||
.ExecuteAction();
|
||||
}
|
||||
|
||||
public async Task PostMovie(MovieRequest data, Action<MovieResponse>? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null)
|
||||
{
|
||||
string url = GetUrl(EndpointsConfiguration.Movies.PostMovie);
|
||||
|
||||
HttpRequest request = new HttpRequest(HttpMethodType.Post, url);
|
||||
request.Body = data;
|
||||
@@ -57,21 +74,9 @@ public class MoviesWebAPIService : BaseWebAPIService, IMoviesWebAPIService
|
||||
.ExecuteAction();
|
||||
}
|
||||
|
||||
public async Task Get(long id, Action<MovieResponse>? successAction = null, Action? notFoundAction = null)
|
||||
public async Task PutMovie(long id, MovieRequest data, Action? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null)
|
||||
{
|
||||
string url = GetUrl(EndpointsConfiguration.Movies.Get, id);
|
||||
|
||||
HttpRequest request = new HttpRequest(HttpMethodType.Get, url);
|
||||
|
||||
HttpResponse response = await _httpClientService.SendRequestAsync(request);
|
||||
response.RegisterActionFor2XXSuccess(successAction)
|
||||
.RegisterActionFor404NotFound(notFoundAction)
|
||||
.ExecuteAction();
|
||||
}
|
||||
|
||||
public async Task Put(long id, MovieRequest data, Action? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null)
|
||||
{
|
||||
string url = GetUrl(EndpointsConfiguration.Movies.Put, id);
|
||||
string url = GetUrl(EndpointsConfiguration.Movies.PutMovie, id);
|
||||
|
||||
HttpRequest request = new HttpRequest(HttpMethodType.Put, url);
|
||||
request.Body = data;
|
||||
@@ -84,9 +89,9 @@ public class MoviesWebAPIService : BaseWebAPIService, IMoviesWebAPIService
|
||||
.ExecuteAction();
|
||||
}
|
||||
|
||||
public async Task Delete(long id, Action? successAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null)
|
||||
public async Task DeleteMovie(long id, Action? successAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null)
|
||||
{
|
||||
string url = GetUrl(EndpointsConfiguration.Movies.Delete, id);
|
||||
string url = GetUrl(EndpointsConfiguration.Movies.DeleteMovie, id);
|
||||
|
||||
HttpRequest request = new HttpRequest(HttpMethodType.Delete, url);
|
||||
|
||||
@@ -96,6 +101,44 @@ public class MoviesWebAPIService : BaseWebAPIService, IMoviesWebAPIService
|
||||
.RegisterActionFor403Forbidden(forbiddenAction)
|
||||
.ExecuteAction();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region View count
|
||||
|
||||
public async Task GetMoviesViewRank(int? first = null, int? days = null, Action<IEnumerable<MovieResponse>>? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null)
|
||||
{
|
||||
string url = GetUrl(EndpointsConfiguration.Movies.GetMoviesViewRank);
|
||||
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();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ public partial class MediaPage : ComponentBase
|
||||
MediaWebAPIService.GetPoster(Id, data => _poster = data),
|
||||
MediaWebAPIService.GetMediaGenres(Id, data => _genres = data),
|
||||
MediaWebAPIService.GetMediaRating(Id, data => _globalRating = data),
|
||||
_media.Type == MediaType.Movie ? MoviesWebAPIService.Get(Id, data => _movie = data) : Task.CompletedTask,
|
||||
_media.Type == MediaType.Movie ? MoviesWebAPIService.GetMovie(Id, data => _movie = data) : Task.CompletedTask,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ public partial class MovieEditPage : ComponentBase
|
||||
{
|
||||
if (Id is not null)
|
||||
{
|
||||
await MoviesWebAPIService.Get(Id.Value, GetSuccessAction, NoIdAction);
|
||||
await MoviesWebAPIService.GetMovie(Id.Value, GetSuccessAction, NoIdAction);
|
||||
}
|
||||
|
||||
return;
|
||||
@@ -83,11 +83,11 @@ public partial class MovieEditPage : ComponentBase
|
||||
_movieDataInfo = null;
|
||||
if (Id is null)
|
||||
{
|
||||
await MoviesWebAPIService.Post(_movieData, PostSuccessAction, BadRequestAction, NoPermissionsAction, NoPermissionsAction);
|
||||
await MoviesWebAPIService.PostMovie(_movieData, PostSuccessAction, BadRequestAction, NoPermissionsAction, NoPermissionsAction);
|
||||
}
|
||||
else
|
||||
{
|
||||
await MoviesWebAPIService.Put(Id.Value, _movieData, PutSuccessAction, BadRequestAction, NoPermissionsAction, NoPermissionsAction);
|
||||
await MoviesWebAPIService.PutMovie(Id.Value, _movieData, PutSuccessAction, BadRequestAction, NoPermissionsAction, NoPermissionsAction);
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
@@ -28,14 +28,6 @@
|
||||
"Put": "/{0}",
|
||||
"Delete": "/{0}"
|
||||
},
|
||||
"Movies": {
|
||||
"Base": "/movies",
|
||||
"GetAll": "",
|
||||
"Get": "/{0}",
|
||||
"Post": "",
|
||||
"Put": "/{0}",
|
||||
"Delete": "/{0}"
|
||||
},
|
||||
"Media": {
|
||||
"Base": "/media",
|
||||
"Get": "/{0}",
|
||||
@@ -58,6 +50,24 @@
|
||||
"PostPhoto": "/photos",
|
||||
"PutPhoto": "/photos/{0}",
|
||||
"DeletePhoto": "/photos/{0}"
|
||||
},
|
||||
"Movies": {
|
||||
"Base": "/movies",
|
||||
"GetAll": "",
|
||||
"Get": "/{0}",
|
||||
"Post": "",
|
||||
"Put": "/{0}",
|
||||
"Delete": "/{0}",
|
||||
"GetMoviesViewRank": "/view"
|
||||
},
|
||||
"Series": {
|
||||
"Base": "/series",
|
||||
"GetAllSeries": "",
|
||||
"GetSeries": "/{0}",
|
||||
"PostSeries": "",
|
||||
"PutSeries": "/{0}",
|
||||
"DeleteSeries": "/{0}",
|
||||
"GetSeriesViewRank": "/view"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user