Mineplex2018-withcommit/Website/Nautilus.Web.Impulse/Controllers/PlayerAccountController.cs
Jonathan Williams 3fb52c5c71 Initial Commit
2013-08-27 08:14:08 -07:00

91 lines
2.7 KiB
C#

namespace LOC.Website.Web.Controllers
{
using System.Web.Mvc;
using Common.Models;
using Core.Model.Account;
using Core.Tokens;
using Core.Tokens.Client;
using Newtonsoft.Json;
public class PlayerAccountController : Controller
{
private readonly IAccountAdministrator _accountAdministrator;
public PlayerAccountController(IAccountAdministrator accountAdministrator)
{
_accountAdministrator = accountAdministrator;
}
[HttpPost]
public ActionResult GetAccountNames()
{
var accountNames = _accountAdministrator.GetAccountNames();
var json = JsonConvert.SerializeObject(accountNames);
return Content(json, "application/json");
}
[HttpPost]
public ActionResult GetAccount(string name)
{
var account = _accountAdministrator.GetAccountByName(name);
var json = JsonConvert.SerializeObject(account);
return Content(json, "application/json");
}
[HttpPost]
public ActionResult GetBan(string name)
{
var account = _accountAdministrator.GetAccountByName(name);
var json = JsonConvert.SerializeObject(account);
return Content(json, "application/json");
}
[HttpPost]
public ActionResult GetDonor(string name)
{
var account = _accountAdministrator.GetAccountByName(name);
var json = JsonConvert.SerializeObject(account);
return Content(json, "application/json");
}
[HttpPost]
public ActionResult Login(LoginToken loginToken)
{
_accountAdministrator.Login(loginToken);
var account = _accountAdministrator.GetAccountByName(loginToken.Name);
var json = JsonConvert.SerializeObject(new ClientToken(account));
return Content(json, "application/json");
}
[HttpPost]
public ActionResult PurchaseSalesPackage(PurchaseToken token)
{
var json = JsonConvert.SerializeObject(_accountAdministrator.PurchaseGameSalesPackage(token));
return Content(json, "application/json");
}
[HttpPost]
public void Logout(string name)
{
_accountAdministrator.Logout(name);
}
[HttpPost]
public ActionResult AccountExists(string name)
{
var json = JsonConvert.SerializeObject(_accountAdministrator.AccountExists(name));
return Content(json, "application/json");
}
[HttpPost]
public void Ban(PunishToken punish)
{
_accountAdministrator.BanAccount(punish);
}
}
}