@ -2,6 +2,8 @@ using Nancy;
using Nancy.Responses.Negotiation ;
using RequestPlex.Api ;
using RequestPlex.Core ;
using RequestPlex.Store ;
namespace RequestPlex.UI.Modules
{
@ -34,7 +36,7 @@ namespace RequestPlex.UI.Modules
Post [ "search/request/tv" ] = parameters = >
{
var tvShowId = ( int ) Request . Form . show Id;
var tvShowId = ( int ) Request . Form . tv Id;
var latest = ( bool ) Request . Form . latestSeason ;
return RequestTvShow ( tvShowId , latest ) ;
} ;
@ -47,6 +49,7 @@ namespace RequestPlex.UI.Modules
private Response SearchMovie ( string searchTerm )
{
var s = new SettingsService ( ) ;
var api = new TheMovieDbApi ( ) ;
var movies = api . SearchMovie ( searchTerm ) ;
var result = movies . Result ;
@ -79,12 +82,21 @@ namespace RequestPlex.UI.Modules
private Response RequestMovie ( int movieId )
{
return Response . AsJson ( "" ) ;
var s = new SettingsService ( ) ;
if ( s . CheckRequest ( movieId ) )
{
return Response . AsJson ( new { Result = false , Message = "Movie has already been requested!" } ) ;
}
s . AddRequest ( movieId , RequestType . Movie ) ;
return Response . AsJson ( new { Result = true } ) ;
}
private Response RequestTvShow ( int showId , bool latest )
{
return Response . AsJson ( "" ) ;
// Latest send to Sonarr and no need to store in DB
var s = new SettingsService ( ) ;
s . AddRequest ( showId , RequestType . TvShow ) ;
return Response . AsJson ( new { Result = true } ) ;
}
}
}