OpenAuth.Net/OpenAuth.Mvc/Controllers/ModuleElementManagerController.cs

89 lines
2.8 KiB
C#
Raw Normal View History

// ***********************************************************************
// Assembly : OpenAuth.Mvc
// Author : Yubao Li
// Created : 12-02-2015
//
// Last Modified By : Yubao Li
// Last Modified On : 12-02-2015
// ***********************************************************************
// <copyright file="ModuleElementManagerController.cs" company="">
// Copyright (c) . All rights reserved.
// </copyright>
// <summary>模块元素管理,无需权限控制</summary>
// ***********************************************************************
using Infrastructure;
using OpenAuth.App;
using OpenAuth.Domain;
using OpenAuth.Mvc.Models;
2016-04-18 23:36:40 +08:00
using System;
using System.Data.Entity.Validation;
using System.Web.Mvc;
namespace OpenAuth.Mvc.Controllers
{
public class ModuleElementManagerController : BaseController
{
private ModuleElementManagerApp _app;
public ModuleElementManagerController()
{
_app = AutofacExt.GetFromFac<ModuleElementManagerApp>();
}
public ActionResult Index(Guid id)
{
ViewBag.ModuleId = id;
return View();
}
public ActionResult Get(Guid moduleId)
{
2016-10-18 11:11:51 +08:00
return Json(_app.LoadByModuleId(moduleId), JsonRequestBehavior.AllowGet);
}
[HttpPost]
public string AddOrEditButton(ModuleElement button)
{
try
{
_app.AddOrUpdate(button);
}
catch (DbEntityValidationException e)
{
2016-10-14 11:22:16 +08:00
Result.Status=false;
Result.Message = e.Message;
}
2016-10-14 11:22:16 +08:00
return JsonHelper.Instance.Serialize( Result);
}
2016-10-18 11:11:51 +08:00
public string Del(Guid[] ids)
{
try
{
2016-10-18 11:11:51 +08:00
_app.Delete(ids);
}
catch (Exception e)
{
2016-10-14 11:22:16 +08:00
Result.Status=false;
Result.Message = e.Message;
}
2016-10-14 11:22:16 +08:00
return JsonHelper.Instance.Serialize( Result);
}
2016-01-07 15:55:53 +08:00
/// <summary>
2016-04-18 23:36:40 +08:00
/// 分配模块菜单(按钮)界面
/// <para>可以为用户/角色分配同过keyUserElement/RoleElement区分</para>
2016-01-07 15:55:53 +08:00
/// </summary>
2016-04-18 23:36:40 +08:00
/// <param name="firstId">The first identifier.</param>
/// <param name="key">The key.</param>
/// <returns>ActionResult.</returns>
public ActionResult AssignModuleElement(Guid firstId, string key)
{
2016-04-18 23:36:40 +08:00
ViewBag.FirstId = firstId;
ViewBag.ModuleType = key;
return View();
}
public string LoadWithAccess(Guid tId, Guid firstId, string key)
{
2016-04-18 23:36:40 +08:00
return JsonHelper.Instance.Serialize(_app.LoadWithAccess(key, firstId, tId));
}
}
2015-12-02 16:28:01 +08:00
}