Skip to content

Commit

Permalink
IDK
Browse files Browse the repository at this point in the history
  • Loading branch information
AbreuHD committed Mar 15, 2024
1 parent 23fe6fd commit f251a80
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 3 deletions.
16 changes: 16 additions & 0 deletions Core.Application/DTOs/Movies/MoviePageResponseDTO.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Core.Application.DTOs.Movies
{
public class MoviePageResponseDTO
{
public int Id { get; set; }
public string WebPageTitle { get; set; }
public string URI { get; set; }
}
}
1 change: 1 addition & 0 deletions Core.Application/DTOs/Movies/PreviewSearchMovieDTO.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ namespace Core.Application.DTOs.Movies
{
public class PreviewSearchMovieDTO
{
public int ID { get; set; }
public int TMDBID { get; set; }
public string Title { get; set; }
public bool? Adult { get; set; }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using Core.Application.DTOs.General;
using Core.Application.DTOs.Movies;
using Core.Application.Interface.Repositories;
using MediatR;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Core.Application.Features.Movies.Queries.SearchMoviePages
{
public class SearchMoviePagesQuery : IRequest<GenericApiResponse<MoviePageResponseDTO>>
{
public int MovieId { get; set; }
}

public class SearchMoviePagesQueryHandler : IRequestHandler<SearchMoviePagesQuery, GenericApiResponse<MoviePageResponseDTO>>
{
private readonly IMovieRepository _movieRepository;
private readonly IMovieWebRepository _movieWebRepository;

public SearchMoviePagesQueryHandler(IMovieRepository movieRepository, IMovieWebRepository movieWebRepository)
{
_movieRepository = movieRepository;
_movieWebRepository = movieWebRepository;
}

public async Task<GenericApiResponse<MoviePageResponseDTO>> Handle(SearchMoviePagesQuery request, CancellationToken cancellationToken)
{
var data = await _movieRepository.GetMovieWebPage(request.MovieId);
throw new NotImplementedException();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
using System.Text;
using System.Threading.Tasks;

namespace Core.Application.Features.Movies.Queries
namespace Core.Application.Features.Movies.Queries.SearchMovies
{
public class SearchMoviesQuery : IRequest<GenericApiResponse<List<PreviewSearchMovieDTO>>>
{
Expand All @@ -22,7 +22,7 @@ public class SearchMoviesQueryHandler : IRequestHandler<SearchMoviesQuery, Gener
private readonly IMovieRepository _movieRepository;
private readonly IMapper _mapper;

public SearchMoviesQueryHandler(IMovieRepository movieRepository,IMapper mapper)
public SearchMoviesQueryHandler(IMovieRepository movieRepository, IMapper mapper)
{
_movieRepository = movieRepository;
_mapper = mapper;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ public interface IMovieRepository : IGenericRepository<Movie>
Task<List<Movie>> Exist(List<Movie> movie);
Task<List<Movie_MovieWeb>> GetId(List<Movie_MovieWeb> movie);
Task<(List<Movie>, List<Genre>)> SearchMovies(string Title, List<int> Value = null);
Task<Movie> GetMovieWebPage(int MovieId);
}
}
6 changes: 6 additions & 0 deletions Infraestructure.Persistence/Repositories/MovieRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ public async Task<List<Movie_MovieWeb>> GetId(List<Movie_MovieWeb> movies)
return allMovies;
}

public async Task<Movie> GetMovieWebPage(int MovieId)
{
var response = await _dbContext.Set<Movie>().Include(x => x.Movie_MovieWeb).FirstOrDefaultAsync(x => x.ID == MovieId);
return response;
}

public async Task<(List<Movie>, List<Genre>)> SearchMovies(string Title, List<int> Value = null)
{
var searchKeywords = Title.ToLower().Split(' ');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using Core.Application.DTOs.Account;
using Core.Application.Enum;
using Core.Application.Features.Movies.Queries;
using Core.Application.Features.Movies.Queries.SearchMoviePages;
using Core.Application.Features.Movies.Queries.SearchMovies;
using KuhakuCentral.Controllers.V1.General;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
Expand All @@ -11,7 +13,7 @@ namespace KuhakuCentral.Controllers.V1.Movie
{
public class MovieController : BaseAPI
{
[HttpGet]
[HttpGet("Search")]
[Consumes(MediaTypeNames.Application.Json)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
Expand All @@ -23,5 +25,18 @@ public async Task<IActionResult> Search(string Title, List<int> Values)
{
return Ok(await Mediator.Send(new SearchMoviesQuery { Title = Title, Values = Values}));
}

[HttpGet("Info")]
[Consumes(MediaTypeNames.Application.Json)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
[SwaggerOperation(
Summary = "MovieData",
Description = "Get All Movie Links from Database"
)]
public async Task<IActionResult> Info(int MovieId)
{
return Ok(await Mediator.Send(new SearchMoviePagesQuery { MovieId = MovieId }));
}
}
}

0 comments on commit f251a80

Please sign in to comment.