mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-10 07:22:35 -07:00
Added in deletion of requests
This commit is contained in:
parent
cedd58f372
commit
754ace42b0
7 changed files with 103 additions and 75 deletions
|
@ -13,13 +13,18 @@ namespace RequestPlex.UI.Modules
|
|||
public class RequestsModule : NancyModule
|
||||
{
|
||||
private IRepository<RequestedModel> Service { get; set; }
|
||||
public RequestsModule(IRepository<RequestedModel> service)
|
||||
public RequestsModule(IRepository<RequestedModel> service) : base("requests")
|
||||
{
|
||||
Service = service;
|
||||
|
||||
Get["requests/"] = _ => LoadRequests();
|
||||
Get["requests/movies"] = _ => GetMovies();
|
||||
Get["requests/tvshows"] = _ => GetTvShows();
|
||||
Get["/"] = _ => LoadRequests();
|
||||
Get["/movies"] = _ => GetMovies();
|
||||
Get["/tvshows"] = _ => GetTvShows();
|
||||
Post["/delete"] = _ =>
|
||||
{
|
||||
var convertedType = (string)Request.Form.type == "movie" ? RequestType.Movie : RequestType.TvShow;
|
||||
return Delete((int)Request.Form.id, convertedType);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
@ -39,5 +44,12 @@ namespace RequestPlex.UI.Modules
|
|||
var dbTv = Service.GetAll().Where(x => x.Type == RequestType.TvShow);
|
||||
return Response.AsJson(dbTv);
|
||||
}
|
||||
|
||||
private Response Delete(int tmdbId, RequestType type)
|
||||
{
|
||||
var currentEntity = Service.GetAll().FirstOrDefault(x => x.Tmdbid == tmdbId && x.Type == type);
|
||||
Service.Delete(currentEntity);
|
||||
return Response.AsJson(new { Result = true });
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue