mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-08 06:00:50 -07:00
Started #273
This commit is contained in:
parent
247ef4833a
commit
ae4d51de9b
14 changed files with 562 additions and 195 deletions
51
PlexRequests.UI/Modules/IssuesModule.cs
Normal file
51
PlexRequests.UI/Modules/IssuesModule.cs
Normal file
|
@ -0,0 +1,51 @@
|
|||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using Nancy;
|
||||
using Nancy.Responses.Negotiation;
|
||||
|
||||
using PlexRequests.Core;
|
||||
using PlexRequests.Core.SettingModels;
|
||||
|
||||
namespace PlexRequests.UI.Modules
|
||||
{
|
||||
public class IssuesModule : BaseAuthModule
|
||||
{
|
||||
public IssuesModule(ISettingsService<PlexRequestSettings> pr, IIssueService issueService) : base("issues", pr)
|
||||
{
|
||||
IssuesService = issueService;
|
||||
|
||||
Get["/"] = x => Index();
|
||||
|
||||
Get["/issuecount", true] = async (x, ct) => await IssueCount();
|
||||
|
||||
Get["/details/{id}", true] = async (x, ct) => await Details(x.id);
|
||||
}
|
||||
|
||||
private IIssueService IssuesService { get; }
|
||||
|
||||
public Negotiator Index()
|
||||
{
|
||||
return View["Index"];
|
||||
}
|
||||
|
||||
public async Task<Response> IssueCount()
|
||||
{
|
||||
var issues = await IssuesService.GetAllAsync();
|
||||
var count = issues.Count(x => x.Deleted == false);
|
||||
|
||||
return Response.AsJson(count);
|
||||
}
|
||||
|
||||
public async Task<Negotiator> Details(int id)
|
||||
{
|
||||
var issue = await IssuesService.GetAsync(id);
|
||||
|
||||
return issue == null
|
||||
? Index()
|
||||
: View["Details", issue];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue