Merge pull request #63 from mateuszskoczek/features/tv_series_endpoints
Features/tv series endpoints
This commit is contained in:
9
WatchIt.Common/WatchIt.Common.Model/Series/Series.cs
Normal file
9
WatchIt.Common/WatchIt.Common.Model/Series/Series.cs
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace WatchIt.Common.Model.Series;
|
||||||
|
|
||||||
|
public class Series : Media.Media
|
||||||
|
{
|
||||||
|
[JsonPropertyName("has_ended")]
|
||||||
|
public bool HasEnded { get; set; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using WatchIt.Common.Query;
|
||||||
|
|
||||||
|
namespace WatchIt.Common.Model.Series;
|
||||||
|
|
||||||
|
public class SeriesQueryParameters : QueryParameters<SeriesResponse>
|
||||||
|
{
|
||||||
|
#region PROPERTIES
|
||||||
|
|
||||||
|
[FromQuery(Name = "title")]
|
||||||
|
public string? Title { get; set; }
|
||||||
|
|
||||||
|
[FromQuery(Name = "original_title")]
|
||||||
|
public string? OriginalTitle { get; set; }
|
||||||
|
|
||||||
|
[FromQuery(Name = "description")]
|
||||||
|
public string? Description { get; set; }
|
||||||
|
|
||||||
|
[FromQuery(Name = "release_date")]
|
||||||
|
public DateOnly? ReleaseDate { get; set; }
|
||||||
|
|
||||||
|
[FromQuery(Name = "release_date_from")]
|
||||||
|
public DateOnly? ReleaseDateFrom { get; set; }
|
||||||
|
|
||||||
|
[FromQuery(Name = "release_date_to")]
|
||||||
|
public DateOnly? ReleaseDateTo { get; set; }
|
||||||
|
|
||||||
|
[FromQuery(Name = "length")]
|
||||||
|
public short? Length { get; set; }
|
||||||
|
|
||||||
|
[FromQuery(Name = "length_from")]
|
||||||
|
public short? LengthFrom { get; set; }
|
||||||
|
|
||||||
|
[FromQuery(Name = "length_to")]
|
||||||
|
public short? LengthTo { get; set; }
|
||||||
|
|
||||||
|
[FromQuery(Name = "has_ended")]
|
||||||
|
public bool? HasEnded { get; set; }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#region PUBLIC METHODS
|
||||||
|
|
||||||
|
public override bool IsMeetingConditions(SeriesResponse item) =>
|
||||||
|
(
|
||||||
|
TestString(item.Title, Title)
|
||||||
|
&&
|
||||||
|
TestString(item.OriginalTitle, OriginalTitle)
|
||||||
|
&&
|
||||||
|
TestString(item.Description, Description)
|
||||||
|
&&
|
||||||
|
TestComparable(item.ReleaseDate, ReleaseDate, ReleaseDateFrom, ReleaseDateTo)
|
||||||
|
&&
|
||||||
|
TestComparable(item.Length, Length, LengthFrom, LengthTo)
|
||||||
|
&&
|
||||||
|
TestBoolean(item.HasEnded, HasEnded)
|
||||||
|
);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
59
WatchIt.Common/WatchIt.Common.Model/Series/SeriesRequest.cs
Normal file
59
WatchIt.Common/WatchIt.Common.Model/Series/SeriesRequest.cs
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
using System.Diagnostics.CodeAnalysis;
|
||||||
|
using WatchIt.Database.Model.Media;
|
||||||
|
|
||||||
|
namespace WatchIt.Common.Model.Series;
|
||||||
|
|
||||||
|
public class SeriesRequest : Series
|
||||||
|
{
|
||||||
|
#region CONSTRUCTORS
|
||||||
|
|
||||||
|
[SetsRequiredMembers]
|
||||||
|
public SeriesRequest(SeriesResponse initData)
|
||||||
|
{
|
||||||
|
Title = initData.Title;
|
||||||
|
OriginalTitle = initData.OriginalTitle;
|
||||||
|
Description = initData.Description;
|
||||||
|
ReleaseDate = initData.ReleaseDate;
|
||||||
|
Length = initData.Length;
|
||||||
|
HasEnded = initData.HasEnded;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SeriesRequest() {}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#region PUBLIC METHODS
|
||||||
|
|
||||||
|
public Database.Model.Media.Media CreateMedia() => new Database.Model.Media.Media
|
||||||
|
{
|
||||||
|
Title = Title,
|
||||||
|
OriginalTitle = OriginalTitle,
|
||||||
|
Description = Description,
|
||||||
|
ReleaseDate = ReleaseDate,
|
||||||
|
Length = Length,
|
||||||
|
};
|
||||||
|
|
||||||
|
public MediaSeries CreateMediaSeries(long id) => new MediaSeries
|
||||||
|
{
|
||||||
|
Id = id,
|
||||||
|
HasEnded = HasEnded,
|
||||||
|
};
|
||||||
|
|
||||||
|
public void UpdateMedia(Database.Model.Media.Media media)
|
||||||
|
{
|
||||||
|
media.Title = Title;
|
||||||
|
media.OriginalTitle = OriginalTitle;
|
||||||
|
media.Description = Description;
|
||||||
|
media.ReleaseDate = ReleaseDate;
|
||||||
|
media.Length = Length;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void UpdateMediaSeries(MediaSeries mediaSeries)
|
||||||
|
{
|
||||||
|
mediaSeries.HasEnded = HasEnded;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
36
WatchIt.Common/WatchIt.Common.Model/Series/SeriesResponse.cs
Normal file
36
WatchIt.Common/WatchIt.Common.Model/Series/SeriesResponse.cs
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
using System.Diagnostics.CodeAnalysis;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
using WatchIt.Database.Model.Media;
|
||||||
|
|
||||||
|
namespace WatchIt.Common.Model.Series;
|
||||||
|
|
||||||
|
public class SeriesResponse : Series
|
||||||
|
{
|
||||||
|
#region PROPERTIES
|
||||||
|
|
||||||
|
[JsonPropertyName("id")]
|
||||||
|
public long Id { get; set; }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#region CONSTRUCTORS
|
||||||
|
|
||||||
|
[JsonConstructor]
|
||||||
|
public SeriesResponse() {}
|
||||||
|
|
||||||
|
[SetsRequiredMembers]
|
||||||
|
public SeriesResponse(MediaSeries mediaSeries)
|
||||||
|
{
|
||||||
|
Id = mediaSeries.Media.Id;
|
||||||
|
Title = mediaSeries.Media.Title;
|
||||||
|
OriginalTitle = mediaSeries.Media.OriginalTitle;
|
||||||
|
Description = mediaSeries.Media.Description;
|
||||||
|
ReleaseDate = mediaSeries.Media.ReleaseDate;
|
||||||
|
Length = mediaSeries.Media.Length;
|
||||||
|
HasEnded = mediaSeries.HasEnded;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
@@ -57,7 +57,7 @@ public class MoviesController : ControllerBase
|
|||||||
|
|
||||||
[HttpPut("{id}")]
|
[HttpPut("{id}")]
|
||||||
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
|
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
|
||||||
[ProducesResponseType(typeof(void), StatusCodes.Status204NoContent)]
|
[ProducesResponseType(typeof(void), StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
|
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
|
||||||
[ProducesResponseType(typeof(void), StatusCodes.Status401Unauthorized)]
|
[ProducesResponseType(typeof(void), StatusCodes.Status401Unauthorized)]
|
||||||
[ProducesResponseType(typeof(void), StatusCodes.Status403Forbidden)]
|
[ProducesResponseType(typeof(void), StatusCodes.Status403Forbidden)]
|
||||||
|
|||||||
@@ -0,0 +1,85 @@
|
|||||||
|
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using WatchIt.Common.Model.Series;
|
||||||
|
using WatchIt.Database;
|
||||||
|
using WatchIt.WebAPI.Services.Controllers.Series;
|
||||||
|
|
||||||
|
namespace WatchIt.WebAPI.Controllers;
|
||||||
|
|
||||||
|
[ApiController]
|
||||||
|
[Route("series")]
|
||||||
|
public class SeriesController : ControllerBase
|
||||||
|
{
|
||||||
|
#region SERVICES
|
||||||
|
|
||||||
|
private readonly ISeriesControllerService _seriesControllerService;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#region CONSTRUCTORS
|
||||||
|
|
||||||
|
public SeriesController(ISeriesControllerService seriesControllerService)
|
||||||
|
{
|
||||||
|
_seriesControllerService = seriesControllerService;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#region PUBLIC METHODS
|
||||||
|
|
||||||
|
#region Main
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
[AllowAnonymous]
|
||||||
|
[ProducesResponseType(typeof(IEnumerable<SeriesResponse>), StatusCodes.Status200OK)]
|
||||||
|
public async Task<ActionResult> GetAllSeries(SeriesQueryParameters query) => await _seriesControllerService.GetAllSeries(query);
|
||||||
|
|
||||||
|
[HttpGet("{id}")]
|
||||||
|
[AllowAnonymous]
|
||||||
|
[ProducesResponseType(typeof(SeriesResponse), StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||||
|
public async Task<ActionResult> GetSeries([FromRoute] long id) => await _seriesControllerService.GetSeries(id);
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
|
||||||
|
[ProducesResponseType(typeof(SeriesResponse), StatusCodes.Status201Created)]
|
||||||
|
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
|
||||||
|
[ProducesResponseType(typeof(void), StatusCodes.Status401Unauthorized)]
|
||||||
|
[ProducesResponseType(typeof(void), StatusCodes.Status403Forbidden)]
|
||||||
|
public async Task<ActionResult> PostSeries([FromBody] SeriesRequest body) => await _seriesControllerService.PostSeries(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> PutSeries([FromRoute] long id, [FromBody]SeriesRequest body) => await _seriesControllerService.PutSeries(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> DeleteSeries([FromRoute] long id) => await _seriesControllerService.DeleteSeries(id);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region View count
|
||||||
|
|
||||||
|
[HttpGet("view")]
|
||||||
|
[AllowAnonymous]
|
||||||
|
[ProducesResponseType(typeof(IEnumerable<SeriesResponse>), StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
|
public async Task<ActionResult> GetSeriesViewRank([FromQuery] int first = 5, [FromQuery] int days = 7) => await _seriesControllerService.GetSeriesViewRank(first, days);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
@@ -17,6 +17,7 @@
|
|||||||
<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.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.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.Movies\WatchIt.WebAPI.Services.Controllers.Movies.csproj" />
|
||||||
|
<ProjectReference Include="..\WatchIt.WebAPI.Services\WatchIt.WebAPI.Services.Controllers\WatchIt.WebAPI.Services.Controllers.Series\WatchIt.WebAPI.Services.Controllers.Series.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ public class MoviesControllerService : IMoviesControllerService
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#region PUBLIC METHODS
|
#region PUBLIC METHODS
|
||||||
|
|
||||||
#region Main
|
#region Main
|
||||||
@@ -90,7 +91,7 @@ public class MoviesControllerService : IMoviesControllerService
|
|||||||
data.UpdateMedia(item.Media);
|
data.UpdateMedia(item.Media);
|
||||||
await _database.SaveChangesAsync();
|
await _database.SaveChangesAsync();
|
||||||
|
|
||||||
return RequestResult.NoContent();
|
return RequestResult.Ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<RequestResult> DeleteMovie(long id)
|
public async Task<RequestResult> DeleteMovie(long id)
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
using WatchIt.Common.Model.Series;
|
||||||
|
using WatchIt.WebAPI.Services.Controllers.Common;
|
||||||
|
|
||||||
|
namespace WatchIt.WebAPI.Services.Controllers.Series;
|
||||||
|
|
||||||
|
public interface ISeriesControllerService
|
||||||
|
{
|
||||||
|
Task<RequestResult> GetAllSeries(SeriesQueryParameters query);
|
||||||
|
Task<RequestResult> GetSeries(long id);
|
||||||
|
Task<RequestResult> PostSeries(SeriesRequest data);
|
||||||
|
Task<RequestResult> PutSeries(long id, SeriesRequest data);
|
||||||
|
Task<RequestResult> DeleteSeries(long id);
|
||||||
|
|
||||||
|
Task<RequestResult> GetSeriesViewRank(int first, int days);
|
||||||
|
}
|
||||||
@@ -0,0 +1,162 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using WatchIt.Common.Model.Series;
|
||||||
|
using WatchIt.Database;
|
||||||
|
using WatchIt.Database.Model.Media;
|
||||||
|
using WatchIt.WebAPI.Services.Controllers.Common;
|
||||||
|
using WatchIt.WebAPI.Services.Utility.User;
|
||||||
|
|
||||||
|
namespace WatchIt.WebAPI.Services.Controllers.Series;
|
||||||
|
|
||||||
|
public class SeriesControllerService : ISeriesControllerService
|
||||||
|
{
|
||||||
|
#region SERVICES
|
||||||
|
|
||||||
|
private readonly DatabaseContext _database;
|
||||||
|
|
||||||
|
private readonly IUserService _userService;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#region CONSTRUCTORS
|
||||||
|
|
||||||
|
public SeriesControllerService(DatabaseContext database, IUserService userService)
|
||||||
|
{
|
||||||
|
_database = database;
|
||||||
|
|
||||||
|
_userService = userService;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#region PUBLIC METHODS
|
||||||
|
|
||||||
|
#region Main
|
||||||
|
|
||||||
|
public async Task<RequestResult> GetAllSeries(SeriesQueryParameters query)
|
||||||
|
{
|
||||||
|
IEnumerable<SeriesResponse> data = await _database.MediaSeries.Select(x => new SeriesResponse(x)).ToListAsync();
|
||||||
|
data = query.PrepareData(data);
|
||||||
|
return RequestResult.Ok(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<RequestResult> GetSeries(long id)
|
||||||
|
{
|
||||||
|
MediaSeries? item = await _database.MediaSeries.FirstOrDefaultAsync(x => x.Id == id);
|
||||||
|
if (item is null)
|
||||||
|
{
|
||||||
|
return RequestResult.NotFound();
|
||||||
|
}
|
||||||
|
|
||||||
|
SeriesResponse data = new SeriesResponse(item);
|
||||||
|
return RequestResult.Ok(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<RequestResult> PostSeries(SeriesRequest data)
|
||||||
|
{
|
||||||
|
UserValidator validator = _userService.GetValidator().MustBeAdmin();
|
||||||
|
if (!validator.IsValid)
|
||||||
|
{
|
||||||
|
return RequestResult.Forbidden();
|
||||||
|
}
|
||||||
|
|
||||||
|
Media mediaItem = data.CreateMedia();
|
||||||
|
await _database.Media.AddAsync(mediaItem);
|
||||||
|
await _database.SaveChangesAsync();
|
||||||
|
MediaSeries mediaSeriesItem = data.CreateMediaSeries(mediaItem.Id);
|
||||||
|
await _database.MediaSeries.AddAsync(mediaSeriesItem);
|
||||||
|
await _database.SaveChangesAsync();
|
||||||
|
|
||||||
|
return RequestResult.Created($"series/{mediaItem.Id}", new SeriesResponse(mediaSeriesItem));
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<RequestResult> PutSeries(long id, SeriesRequest data)
|
||||||
|
{
|
||||||
|
UserValidator validator = _userService.GetValidator().MustBeAdmin();
|
||||||
|
if (!validator.IsValid)
|
||||||
|
{
|
||||||
|
return RequestResult.Forbidden();
|
||||||
|
}
|
||||||
|
|
||||||
|
MediaSeries? item = await _database.MediaSeries.FirstOrDefaultAsync(x => x.Id == id);
|
||||||
|
if (item is null)
|
||||||
|
{
|
||||||
|
return RequestResult.NotFound();
|
||||||
|
}
|
||||||
|
|
||||||
|
data.UpdateMediaSeries(item);
|
||||||
|
data.UpdateMedia(item.Media);
|
||||||
|
await _database.SaveChangesAsync();
|
||||||
|
|
||||||
|
return RequestResult.Ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<RequestResult> DeleteSeries(long id)
|
||||||
|
{
|
||||||
|
UserValidator validator = _userService.GetValidator().MustBeAdmin();
|
||||||
|
if (!validator.IsValid)
|
||||||
|
{
|
||||||
|
return RequestResult.Forbidden();
|
||||||
|
}
|
||||||
|
|
||||||
|
MediaSeries? item = await _database.MediaSeries.FirstOrDefaultAsync(x => x.Id == id);
|
||||||
|
if (item is null)
|
||||||
|
{
|
||||||
|
return RequestResult.NotFound();
|
||||||
|
}
|
||||||
|
|
||||||
|
_database.MediaSeries.Attach(item);
|
||||||
|
_database.MediaSeries.Remove(item);
|
||||||
|
_database.MediaPosterImages.Attach(item.Media.MediaPosterImage!);
|
||||||
|
_database.MediaPosterImages.Remove(item.Media.MediaPosterImage!);
|
||||||
|
_database.MediaPhotoImages.AttachRange(item.Media.MediaPhotoImages);
|
||||||
|
_database.MediaPhotoImages.RemoveRange(item.Media.MediaPhotoImages);
|
||||||
|
_database.MediaGenres.AttachRange(item.Media.MediaGenres);
|
||||||
|
_database.MediaGenres.RemoveRange(item.Media.MediaGenres);
|
||||||
|
_database.MediaProductionCountries.AttachRange(item.Media.MediaProductionCountries);
|
||||||
|
_database.MediaProductionCountries.RemoveRange(item.Media.MediaProductionCountries);
|
||||||
|
_database.PersonActorRoles.AttachRange(item.Media.PersonActorRoles);
|
||||||
|
_database.PersonActorRoles.RemoveRange(item.Media.PersonActorRoles);
|
||||||
|
_database.PersonCreatorRoles.AttachRange(item.Media.PersonCreatorRoles);
|
||||||
|
_database.PersonCreatorRoles.RemoveRange(item.Media.PersonCreatorRoles);
|
||||||
|
_database.RatingsMedia.AttachRange(item.Media.RatingMedia);
|
||||||
|
_database.RatingsMedia.RemoveRange(item.Media.RatingMedia);
|
||||||
|
_database.ViewCountsMedia.AttachRange(item.Media.ViewCountsMedia);
|
||||||
|
_database.ViewCountsMedia.RemoveRange(item.Media.ViewCountsMedia);
|
||||||
|
_database.Media.Attach(item.Media);
|
||||||
|
_database.Media.Remove(item.Media);
|
||||||
|
await _database.SaveChangesAsync();
|
||||||
|
|
||||||
|
return RequestResult.NoContent();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region View count
|
||||||
|
|
||||||
|
public async Task<RequestResult> GetSeriesViewRank(int first, int days)
|
||||||
|
{
|
||||||
|
if (first < 1 || days < 1)
|
||||||
|
{
|
||||||
|
return RequestResult.BadRequest();
|
||||||
|
}
|
||||||
|
|
||||||
|
DateOnly startDate = DateOnly.FromDateTime(DateTime.Now).AddDays(-days);
|
||||||
|
IEnumerable<MediaSeries> rawData = await _database.MediaSeries.OrderByDescending(x => x.Media.ViewCountsMedia.Where(y => y.Date >= startDate)
|
||||||
|
.Sum(y => y.ViewCount))
|
||||||
|
.ThenBy(x => x.Id)
|
||||||
|
.Take(first)
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
|
IEnumerable<SeriesResponse> data = rawData.Select(x => new SeriesResponse(x));
|
||||||
|
|
||||||
|
return RequestResult.Ok(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
#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>
|
||||||
@@ -13,6 +13,7 @@ using WatchIt.WebAPI.Services.Controllers.Accounts;
|
|||||||
using WatchIt.WebAPI.Services.Controllers.Genres;
|
using WatchIt.WebAPI.Services.Controllers.Genres;
|
||||||
using WatchIt.WebAPI.Services.Controllers.Media;
|
using WatchIt.WebAPI.Services.Controllers.Media;
|
||||||
using WatchIt.WebAPI.Services.Controllers.Movies;
|
using WatchIt.WebAPI.Services.Controllers.Movies;
|
||||||
|
using WatchIt.WebAPI.Services.Controllers.Series;
|
||||||
using WatchIt.WebAPI.Services.Utility.Configuration;
|
using WatchIt.WebAPI.Services.Utility.Configuration;
|
||||||
using WatchIt.WebAPI.Services.Utility.Tokens;
|
using WatchIt.WebAPI.Services.Utility.Tokens;
|
||||||
using WatchIt.WebAPI.Services.Utility.User;
|
using WatchIt.WebAPI.Services.Utility.User;
|
||||||
@@ -149,6 +150,7 @@ public static class Program
|
|||||||
builder.Services.AddTransient<IGenresControllerService, GenresControllerService>();
|
builder.Services.AddTransient<IGenresControllerService, GenresControllerService>();
|
||||||
builder.Services.AddTransient<IMoviesControllerService, MoviesControllerService>();
|
builder.Services.AddTransient<IMoviesControllerService, MoviesControllerService>();
|
||||||
builder.Services.AddTransient<IMediaControllerService, MediaControllerService>();
|
builder.Services.AddTransient<IMediaControllerService, MediaControllerService>();
|
||||||
|
builder.Services.AddTransient<ISeriesControllerService, SeriesControllerService>();
|
||||||
|
|
||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ public class Endpoints
|
|||||||
public string Base { get; set; }
|
public string Base { get; set; }
|
||||||
public Accounts Accounts { get; set; }
|
public Accounts Accounts { get; set; }
|
||||||
public Genres Genres { get; set; }
|
public Genres Genres { get; set; }
|
||||||
public Movies Movies { get; set; }
|
|
||||||
public Media Media { 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 class Movies
|
||||||
{
|
{
|
||||||
public string Base { get; set; }
|
public string Base { get; set; }
|
||||||
public string GetAll { get; set; }
|
public string GetAllMovies { get; set; }
|
||||||
public string Get { get; set; }
|
public string GetMovie { get; set; }
|
||||||
public string Post { get; set; }
|
public string PostMovie { get; set; }
|
||||||
public string Put { get; set; }
|
public string PutMovie { get; set; }
|
||||||
public string Delete { 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
|
public interface IMoviesWebAPIService
|
||||||
{
|
{
|
||||||
Task GetAll(MovieQueryParameters? query = null, Action<IEnumerable<MovieResponse>>? successAction = null);
|
Task GetAllMovies(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 PostMovie(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 GetMovie(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 PutMovie(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 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.Model.Movies;
|
||||||
using WatchIt.Common.Services.HttpClient;
|
using WatchIt.Common.Services.HttpClient;
|
||||||
using WatchIt.Website.Services.Utility.Configuration;
|
using WatchIt.Website.Services.Utility.Configuration;
|
||||||
@@ -28,11 +30,14 @@ public class MoviesWebAPIService : BaseWebAPIService, IMoviesWebAPIService
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#region PUBLIC METHODS
|
#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);
|
HttpRequest request = new HttpRequest(HttpMethodType.Get, url);
|
||||||
request.Query = query;
|
request.Query = query;
|
||||||
@@ -42,9 +47,21 @@ public class MoviesWebAPIService : BaseWebAPIService, IMoviesWebAPIService
|
|||||||
.ExecuteAction();
|
.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);
|
HttpRequest request = new HttpRequest(HttpMethodType.Post, url);
|
||||||
request.Body = data;
|
request.Body = data;
|
||||||
@@ -57,21 +74,9 @@ public class MoviesWebAPIService : BaseWebAPIService, IMoviesWebAPIService
|
|||||||
.ExecuteAction();
|
.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);
|
string url = GetUrl(EndpointsConfiguration.Movies.PutMovie, 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);
|
|
||||||
|
|
||||||
HttpRequest request = new HttpRequest(HttpMethodType.Put, url);
|
HttpRequest request = new HttpRequest(HttpMethodType.Put, url);
|
||||||
request.Body = data;
|
request.Body = data;
|
||||||
@@ -84,9 +89,9 @@ public class MoviesWebAPIService : BaseWebAPIService, IMoviesWebAPIService
|
|||||||
.ExecuteAction();
|
.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);
|
HttpRequest request = new HttpRequest(HttpMethodType.Delete, url);
|
||||||
|
|
||||||
@@ -96,6 +101,44 @@ public class MoviesWebAPIService : BaseWebAPIService, IMoviesWebAPIService
|
|||||||
.RegisterActionFor403Forbidden(forbiddenAction)
|
.RegisterActionFor403Forbidden(forbiddenAction)
|
||||||
.ExecuteAction();
|
.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
|
#endregion
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
using WatchIt.Common.Model.Series;
|
||||||
|
|
||||||
|
namespace WatchIt.Website.Services.WebAPI.Series;
|
||||||
|
|
||||||
|
public interface ISeriesWebAPIService
|
||||||
|
{
|
||||||
|
Task GetAllSeries(SeriesQueryParameters? query = null, Action<IEnumerable<SeriesResponse>>? successAction = null);
|
||||||
|
Task GetSeries(long id, Action<SeriesResponse>? successAction = null, Action? notFoundAction = null);
|
||||||
|
Task PostSeries(SeriesRequest data, Action<SeriesResponse>? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null);
|
||||||
|
Task PutSeries(long id, SeriesRequest data, Action? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null);
|
||||||
|
Task DeleteSeries(long id, Action? successAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null);
|
||||||
|
|
||||||
|
Task GetSeriesViewRank(int? first = null, int? days = null, Action<IEnumerable<SeriesResponse>>? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null);
|
||||||
|
}
|
||||||
@@ -0,0 +1,150 @@
|
|||||||
|
using System.Text;
|
||||||
|
using WatchIt.Common.Model.Series;
|
||||||
|
using WatchIt.Common.Services.HttpClient;
|
||||||
|
using WatchIt.Website.Services.Utility.Configuration;
|
||||||
|
using WatchIt.Website.Services.WebAPI.Common;
|
||||||
|
|
||||||
|
namespace WatchIt.Website.Services.WebAPI.Series;
|
||||||
|
|
||||||
|
public class SeriesWebAPIService : BaseWebAPIService, ISeriesWebAPIService
|
||||||
|
{
|
||||||
|
#region SERVICES
|
||||||
|
|
||||||
|
private IHttpClientService _httpClientService;
|
||||||
|
private IConfigurationService _configurationService;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#region CONSTRUCTORS
|
||||||
|
|
||||||
|
public SeriesWebAPIService(IHttpClientService httpClientService, IConfigurationService configurationService) : base(configurationService)
|
||||||
|
{
|
||||||
|
_httpClientService = httpClientService;
|
||||||
|
_configurationService = configurationService;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#region PUBLIC METHODS
|
||||||
|
|
||||||
|
#region Main
|
||||||
|
|
||||||
|
public async Task GetAllSeries(SeriesQueryParameters? query = null, Action<IEnumerable<SeriesResponse>>? successAction = null)
|
||||||
|
{
|
||||||
|
string url = GetUrl(EndpointsConfiguration.Series.GetAllSeries);
|
||||||
|
|
||||||
|
HttpRequest request = new HttpRequest(HttpMethodType.Get, url);
|
||||||
|
request.Query = query;
|
||||||
|
|
||||||
|
HttpResponse response = await _httpClientService.SendRequestAsync(request);
|
||||||
|
response.RegisterActionFor2XXSuccess(successAction)
|
||||||
|
.ExecuteAction();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task GetSeries(long id, Action<SeriesResponse>? successAction = null, Action? notFoundAction = null)
|
||||||
|
{
|
||||||
|
string url = GetUrl(EndpointsConfiguration.Series.GetSeries, id);
|
||||||
|
|
||||||
|
HttpRequest request = new HttpRequest(HttpMethodType.Get, url);
|
||||||
|
|
||||||
|
HttpResponse response = await _httpClientService.SendRequestAsync(request);
|
||||||
|
response.RegisterActionFor2XXSuccess(successAction)
|
||||||
|
.RegisterActionFor404NotFound(notFoundAction)
|
||||||
|
.ExecuteAction();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task PostSeries(SeriesRequest data, Action<SeriesResponse>? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null)
|
||||||
|
{
|
||||||
|
string url = GetUrl(EndpointsConfiguration.Series.PostSeries);
|
||||||
|
|
||||||
|
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 PutSeries(long id, SeriesRequest data, Action? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null)
|
||||||
|
{
|
||||||
|
string url = GetUrl(EndpointsConfiguration.Series.PutSeries, 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 DeleteSeries(long id, Action? successAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null)
|
||||||
|
{
|
||||||
|
string url = GetUrl(EndpointsConfiguration.Series.DeleteSeries, 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 GetSeriesViewRank(int? first = null, int? days = null, Action<IEnumerable<SeriesResponse>>? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null)
|
||||||
|
{
|
||||||
|
string url = GetUrl(EndpointsConfiguration.Series.GetSeriesViewRank);
|
||||||
|
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
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#region PRIVATE METHODS
|
||||||
|
|
||||||
|
protected override string GetServiceBase() => EndpointsConfiguration.Series.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>
|
||||||
@@ -84,7 +84,7 @@ public partial class MediaPage : ComponentBase
|
|||||||
MediaWebAPIService.GetPoster(Id, data => _poster = data),
|
MediaWebAPIService.GetPoster(Id, data => _poster = data),
|
||||||
MediaWebAPIService.GetMediaGenres(Id, data => _genres = data),
|
MediaWebAPIService.GetMediaGenres(Id, data => _genres = data),
|
||||||
MediaWebAPIService.GetMediaRating(Id, data => _globalRating = 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)
|
if (Id is not null)
|
||||||
{
|
{
|
||||||
await MoviesWebAPIService.Get(Id.Value, GetSuccessAction, NoIdAction);
|
await MoviesWebAPIService.GetMovie(Id.Value, GetSuccessAction, NoIdAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@@ -83,11 +83,11 @@ public partial class MovieEditPage : ComponentBase
|
|||||||
_movieDataInfo = null;
|
_movieDataInfo = null;
|
||||||
if (Id is null)
|
if (Id is null)
|
||||||
{
|
{
|
||||||
await MoviesWebAPIService.Post(_movieData, PostSuccessAction, BadRequestAction, NoPermissionsAction, NoPermissionsAction);
|
await MoviesWebAPIService.PostMovie(_movieData, PostSuccessAction, BadRequestAction, NoPermissionsAction, NoPermissionsAction);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
await MoviesWebAPIService.Put(Id.Value, _movieData, PutSuccessAction, BadRequestAction, NoPermissionsAction, NoPermissionsAction);
|
await MoviesWebAPIService.PutMovie(Id.Value, _movieData, PutSuccessAction, BadRequestAction, NoPermissionsAction, NoPermissionsAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -28,14 +28,6 @@
|
|||||||
"Put": "/{0}",
|
"Put": "/{0}",
|
||||||
"Delete": "/{0}"
|
"Delete": "/{0}"
|
||||||
},
|
},
|
||||||
"Movies": {
|
|
||||||
"Base": "/movies",
|
|
||||||
"GetAll": "",
|
|
||||||
"Get": "/{0}",
|
|
||||||
"Post": "",
|
|
||||||
"Put": "/{0}",
|
|
||||||
"Delete": "/{0}"
|
|
||||||
},
|
|
||||||
"Media": {
|
"Media": {
|
||||||
"Base": "/media",
|
"Base": "/media",
|
||||||
"Get": "/{0}",
|
"Get": "/{0}",
|
||||||
@@ -58,6 +50,24 @@
|
|||||||
"PostPhoto": "/photos",
|
"PostPhoto": "/photos",
|
||||||
"PutPhoto": "/photos/{0}",
|
"PutPhoto": "/photos/{0}",
|
||||||
"DeletePhoto": "/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"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
14
WatchIt.sln
14
WatchIt.sln
@@ -80,6 +80,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WatchIt.Website.Services.Ut
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WatchIt.Website.Services.Utility.Authentication", "WatchIt.Website\WatchIt.Website.Services\WatchIt.Website.Services.Utility\WatchIt.Website.Services.Utility.Authentication\WatchIt.Website.Services.Utility.Authentication.csproj", "{8720AECA-7084-429A-BA15-49B6622C1A32}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WatchIt.Website.Services.Utility.Authentication", "WatchIt.Website\WatchIt.Website.Services\WatchIt.Website.Services.Utility\WatchIt.Website.Services.Utility.Authentication\WatchIt.Website.Services.Utility.Authentication.csproj", "{8720AECA-7084-429A-BA15-49B6622C1A32}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WatchIt.WebAPI.Services.Controllers.Series", "WatchIt.WebAPI\WatchIt.WebAPI.Services\WatchIt.WebAPI.Services.Controllers\WatchIt.WebAPI.Services.Controllers.Series\WatchIt.WebAPI.Services.Controllers.Series.csproj", "{F8FCEF7B-72EA-48BC-AC68-E11244B067DD}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WatchIt.Website.Services.WebAPI.Series", "WatchIt.Website\WatchIt.Website.Services\WatchIt.Website.Services.WebAPI\WatchIt.Website.Services.WebAPI.Series\WatchIt.Website.Services.WebAPI.Series.csproj", "{783C743A-85BF-4382-BFE5-7A90E3F3B8B6}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@@ -122,6 +126,8 @@ Global
|
|||||||
{2D62ED42-489E-4888-9479-E5A50A0E7D70} = {46E3711F-18BD-4004-AF53-EA4D8643D92F}
|
{2D62ED42-489E-4888-9479-E5A50A0E7D70} = {46E3711F-18BD-4004-AF53-EA4D8643D92F}
|
||||||
{77FDAFDD-E97E-4059-A935-B563B6B0D555} = {130BC8F5-82CE-4EDF-AECB-21594DD41849}
|
{77FDAFDD-E97E-4059-A935-B563B6B0D555} = {130BC8F5-82CE-4EDF-AECB-21594DD41849}
|
||||||
{8720AECA-7084-429A-BA15-49B6622C1A32} = {130BC8F5-82CE-4EDF-AECB-21594DD41849}
|
{8720AECA-7084-429A-BA15-49B6622C1A32} = {130BC8F5-82CE-4EDF-AECB-21594DD41849}
|
||||||
|
{F8FCEF7B-72EA-48BC-AC68-E11244B067DD} = {CEC468DB-CC49-47D3-9E3E-1CC9530C3CE7}
|
||||||
|
{783C743A-85BF-4382-BFE5-7A90E3F3B8B6} = {46E3711F-18BD-4004-AF53-EA4D8643D92F}
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
{23383776-1F27-4B5D-8C7C-57BFF75FA473}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{23383776-1F27-4B5D-8C7C-57BFF75FA473}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
@@ -236,5 +242,13 @@ Global
|
|||||||
{8720AECA-7084-429A-BA15-49B6622C1A32}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{8720AECA-7084-429A-BA15-49B6622C1A32}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{8720AECA-7084-429A-BA15-49B6622C1A32}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{8720AECA-7084-429A-BA15-49B6622C1A32}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{8720AECA-7084-429A-BA15-49B6622C1A32}.Release|Any CPU.Build.0 = Release|Any CPU
|
{8720AECA-7084-429A-BA15-49B6622C1A32}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{F8FCEF7B-72EA-48BC-AC68-E11244B067DD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{F8FCEF7B-72EA-48BC-AC68-E11244B067DD}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{F8FCEF7B-72EA-48BC-AC68-E11244B067DD}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{F8FCEF7B-72EA-48BC-AC68-E11244B067DD}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{783C743A-85BF-4382-BFE5-7A90E3F3B8B6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{783C743A-85BF-4382-BFE5-7A90E3F3B8B6}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{783C743A-85BF-4382-BFE5-7A90E3F3B8B6}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{783C743A-85BF-4382-BFE5-7A90E3F3B8B6}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
|||||||
Reference in New Issue
Block a user