Lots of work!

This commit is contained in:
tidusjar 2016-02-26 14:19:02 +00:00
parent 8f0ca3d1c4
commit 448cd8d92e
52 changed files with 6277 additions and 250 deletions

View file

@ -1,4 +1,10 @@
using System.Dynamic;
using Nancy;
using Nancy.Extensions;
using Nancy.Security;
using RequestPlex.Core;
namespace RequestPlex.UI.Modules
{
@ -6,7 +12,39 @@ namespace RequestPlex.UI.Modules
{
public AdminModule()
{
Get["admin/"] = _ => "Hello!";
this.RequiresAuthentication();
Get["admin/"] = _ =>
{
dynamic model = new ExpandoObject();
model.Errored = Request.Query.error.HasValue;
var s = new SettingsService();
var settings = s.GetSettings();
if (settings != null)
{
model.Port = settings.Port;
}
return View["/Admin/Settings", model];
};
Post["admin/"] = _ =>
{
var portString = (string)Request.Form.portNumber;
int port;
if (!int.TryParse(portString, out port))
{
return Context.GetRedirect("~/admin?error=true");
}
var s = new SettingsService();
s.SaveSettings(port);
return Context.GetRedirect("~/admin");
};
}
}
}