using Bootstrap.Admin.Query;
using Bootstrap.DataAccess;
using Bootstrap.Security;
using Longbow.Web.Mvc;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json.Linq;
using System.Collections.Generic;
using System.Linq;
namespace Bootstrap.Admin.Controllers.Api
{
///
///
///
[Route("api/[controller]")]
public class MenusController : Controller
{
///
///
///
///
///
[HttpGet]
public QueryData Get(QueryMenuOption value)
{
return value.RetrieveData(User.Identity.Name);
}
///
///
///
///
[HttpPost]
public bool Post([FromBody]BootstrapMenu value)
{
return MenuHelper.SaveMenu(value);
}
///
///
///
///
[HttpDelete]
public bool Delete([FromBody]IEnumerable value)
{
return MenuHelper.DeleteMenu(value);
}
///
///
///
///
///
///
[HttpPost("{id}")]
public IEnumerable Post(int id, [FromBody]JObject value)
{
var ret = new List();
dynamic json = value;
switch ((string)json.type)
{
case "role":
ret = MenuHelper.RetrieveMenusByRoleId(id).ToList();
break;
case "user":
ret = BootstrapMenu.RetrieveAllMenus(User.Identity.Name).ToList();
break;
default:
break;
}
return ret;
}
///
///
///
///
///
///
[HttpPut("{id}")]
public bool Put(int id, [FromBody]JObject value)
{
var ret = false;
dynamic json = value;
string menuIds = json.menuIds.ToString();
switch ((string)json.type)
{
case "role":
ret = MenuHelper.SaveMenusByRoleId(id, menuIds);
break;
default:
break;
}
return ret;
}
}
}