2018-03-27 00:54:20 -04:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
2018-04-08 02:44:42 -04:00
|
|
|
|
using SharedLibraryCore;
|
2018-03-27 00:54:20 -04:00
|
|
|
|
using WebfrontCore.ViewModels;
|
|
|
|
|
|
|
|
|
|
namespace WebfrontCore.Controllers
|
|
|
|
|
{
|
|
|
|
|
public class ActionController : BaseController
|
|
|
|
|
{
|
|
|
|
|
public IActionResult BanForm()
|
|
|
|
|
{
|
|
|
|
|
var info = new ActionInfo()
|
|
|
|
|
{
|
|
|
|
|
ActionButtonLabel = "Ban",
|
|
|
|
|
Name = "Ban",
|
|
|
|
|
Inputs = new List<InputInfo>()
|
|
|
|
|
{
|
|
|
|
|
new InputInfo()
|
|
|
|
|
{
|
|
|
|
|
Name = "Reason",
|
2018-04-09 23:33:42 -04:00
|
|
|
|
Label = "Reason",
|
2018-03-27 00:54:20 -04:00
|
|
|
|
Placeholder = ""
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
Action = "BanAsync"
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return View("_ActionForm", info);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task<IActionResult> BanAsync(int targetId, string Reason)
|
|
|
|
|
{
|
|
|
|
|
var server = Manager.GetServers().First();
|
|
|
|
|
|
|
|
|
|
return await Task.FromResult(RedirectToAction("ExecuteAsync", "Console", new
|
|
|
|
|
{
|
|
|
|
|
serverId = server.GetHashCode(),
|
|
|
|
|
command = $"!ban @{targetId} {Reason}"
|
|
|
|
|
}));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IActionResult UnbanForm()
|
|
|
|
|
{
|
|
|
|
|
var info = new ActionInfo()
|
|
|
|
|
{
|
|
|
|
|
ActionButtonLabel = "Unban",
|
|
|
|
|
Name = "Unban",
|
|
|
|
|
Inputs = new List<InputInfo>()
|
|
|
|
|
{
|
|
|
|
|
new InputInfo()
|
|
|
|
|
{
|
|
|
|
|
Name = "Reason",
|
2018-04-09 23:33:42 -04:00
|
|
|
|
Label = "Reason",
|
2018-03-27 00:54:20 -04:00
|
|
|
|
Placeholder = ""
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
Action = "UnbanAsync"
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return View("_ActionForm", info);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task<IActionResult> UnbanAsync(int targetId, string Reason)
|
|
|
|
|
{
|
|
|
|
|
var server = Manager.GetServers().First();
|
|
|
|
|
|
|
|
|
|
return await Task.FromResult(RedirectToAction("ExecuteAsync", "Console", new
|
|
|
|
|
{
|
|
|
|
|
serverId = server.GetHashCode(),
|
|
|
|
|
command = $"!unban @{targetId} {Reason}"
|
|
|
|
|
}));
|
|
|
|
|
}
|
2018-04-04 15:38:34 -04:00
|
|
|
|
|
|
|
|
|
public IActionResult LoginForm()
|
|
|
|
|
{
|
|
|
|
|
var login = new ActionInfo()
|
|
|
|
|
{
|
|
|
|
|
ActionButtonLabel = "Login",
|
|
|
|
|
Name = "Login",
|
|
|
|
|
Inputs = new List<InputInfo>()
|
|
|
|
|
{
|
|
|
|
|
new InputInfo()
|
|
|
|
|
{
|
2018-04-05 18:50:04 -04:00
|
|
|
|
Name = "clientId",
|
|
|
|
|
Label = "Client ID"
|
2018-04-04 15:38:34 -04:00
|
|
|
|
},
|
|
|
|
|
new InputInfo()
|
|
|
|
|
{
|
|
|
|
|
Name = "Password",
|
2018-04-05 18:50:04 -04:00
|
|
|
|
Label ="Password",
|
2018-04-04 15:38:34 -04:00
|
|
|
|
Type = "password",
|
|
|
|
|
}
|
|
|
|
|
},
|
2018-04-05 18:50:04 -04:00
|
|
|
|
Action = "LoginAsync"
|
2018-04-04 15:38:34 -04:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return View("_ActionForm", login);
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-05 18:50:04 -04:00
|
|
|
|
public async Task<IActionResult> LoginAsync(int clientId, string password)
|
2018-04-04 15:38:34 -04:00
|
|
|
|
{
|
2018-04-05 18:50:04 -04:00
|
|
|
|
return await Task.FromResult(RedirectToAction("LoginAsync", "Account", new { clientId, password }));
|
2018-04-04 15:38:34 -04:00
|
|
|
|
}
|
2018-03-27 00:54:20 -04:00
|
|
|
|
}
|
|
|
|
|
}
|