// *********************************************************************** // Assembly : OpenAuth.Mvc // Author : Yubao Li // Created : 12-02-2015 // // Last Modified By : Yubao Li // Last Modified On : 12-02-2015 // *********************************************************************** // // Copyright (c) . All rights reserved. // // 模块元素管理,无需权限控制 // *********************************************************************** using Infrastructure; using OpenAuth.App; using OpenAuth.Domain; using OpenAuth.Mvc.Models; using System; using System.Data.Entity.Validation; using System.Web.Mvc; namespace OpenAuth.Mvc.Controllers { public class ModuleElementManagerController : BaseController { private readonly BjuiResponse _bjuiResponse = new BjuiResponse(); private ModuleElementManagerApp _app; public ModuleElementManagerController() { _app = AutofacExt.GetFromFac(); } public ActionResult Index(Guid id) { ViewBag.ModuleId = id; return View(); } public ActionResult Get(Guid moduleId) { return Json(_app.LoadByModuleId(moduleId)); } [HttpPost] public string AddOrEditButton(ModuleElement button) { try { _app.AddOrUpdate(button); } catch (DbEntityValidationException e) { _bjuiResponse.statusCode = "300"; _bjuiResponse.message = e.Message; } return JsonHelper.Instance.Serialize(_bjuiResponse); } public string Del(string moduleElements) { try { var delObjs = JsonHelper.Instance.Deserialize(moduleElements); _app.Delete(delObjs); } catch (Exception e) { _bjuiResponse.statusCode = "300"; _bjuiResponse.message = e.Message; } return JsonHelper.Instance.Serialize(_bjuiResponse); } /// /// 分配模块菜单(按钮)界面 /// 可以为用户/角色分配,同过key(UserElement/RoleElement)区分 /// /// The first identifier. /// The key. /// ActionResult. public ActionResult AssignModuleElement(Guid firstId, string key) { ViewBag.FirstId = firstId; ViewBag.ModuleType = key; return View(); } public string LoadWithAccess(Guid tId, Guid firstId, string key) { return JsonHelper.Instance.Serialize(_app.LoadWithAccess(key, firstId, tId)); } } }