mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-07 05:31:13 -07:00
Some more work. Need to stop the form submitting on a request
This commit is contained in:
parent
9a78f790a6
commit
96a3970a53
7 changed files with 106 additions and 8 deletions
|
@ -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.showId;
|
||||
var tvShowId = (int)Request.Form.tvId;
|
||||
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 });
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue