Some more work. Need to stop the form submitting on a request

This commit is contained in:
tidusjar 2016-02-26 17:29:20 +00:00
parent 9a78f790a6
commit 96a3970a53
7 changed files with 106 additions and 8 deletions

View file

@ -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 });
}
}
}